日期:2014-05-17  浏览次数:20801 次

IE6下jQuery(js)改变img的src属性图片显示不变的问题
JS代码如下:
JScript code

$("#left_menu li").hover(function(){
        $(this).find("a").css("cursor","pointer");
        var currentSrc = $(this).find("img").attr("src");
        if(currentSrc.indexOf("-on.")==-1){
            var afterSrc = currentSrc.replace(".", "-on.");
            $(this).find("img").attr("src" ,afterSrc);
        }
    },function(){
        var currentSrc = $(this).find("img").attr("src");
        if(currentSrc.indexOf("-on.")!=-1){
            if(!$(this).hasClass("active")){
                var afterSrc = currentSrc.replace("-on.", ".");
                $(this).find("img").attr("src" ,afterSrc);
            }
        }
    });


DOM结构如下:
HTML code

<ul id="left_menu">
        <li cls="/platform/index/index/" class="">
            <a title="" href="/platform/index/index/" class="store_left_home" style="cursor: pointer;">
                <span style="color:#ffffff" class="store_left_number fr">新+</span>
                <img class="fl" src="/platform/images/store-shouye.png">
                <span class="fl">商店首页</span>
            </a>
        </li>
                                                    <li cls="/platform/list/index/" class="">
                <a title="" href="/platform/list/index/" class="store_left_gupiaochi" style="cursor: pointer;">
                    <img class="fl" src="/platform/images/store-gupiaochi.png">
                    <span class="fl">股票池</span>
                </a>
            </li>
                                             <li cls="/platform/app/index/" class="">
                <a title="" href="/platform/app/index/" class="store_left_yingyong" style="cursor: pointer;">
                    <img class="fl" src="/platform/images/store-yingyong.png">
                    <span class="fl">应用</span>
                </a>
            </li>
                               <li cls="/platform/record/index/" class="active">
                 <a title="" href="/platform/record/index/" class="store_left_goumai" style="cursor: pointer;">
                     <img class="fl" src="/platform/images/store-goumai-on.png">
                     <span class="fl">购买记录</span>
                 </a>
             </li>
    </ul>



测试chrome,Firefox,IE7,IE8都是好的,可是IE6怎么都不行!求高人指导

------解决方案--------------------
更改之后看地址是不是变了 代码就不看了 看不懂呀 地址没变说明脚本没有让他改变
------解决方案--------------------
CSS code

 浏览器缓存的问题  好像之前碰到这样类似的问题的
然后给图片加个参数就可以了
如: /platform/images/store-goumai-on.png?t=Math.random();
这样避免浏览器缓存不加载问题

------解决方案--------------------
JScript code



    $("#imgid").mouseover(function(){
        document.getElementById('imgid').src="img/large.png";
        return false;
    });
    
    $("#imgid").mouseout(function(