日期:2014-05-17 浏览次数:20776 次
$("#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);
}
}
});
<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>
浏览器缓存的问题 好像之前碰到这样类似的问题的
然后给图片加个参数就可以了
如: /platform/images/store-goumai-on.png?t=Math.random();
这样避免浏览器缓存不加载问题
$("#imgid").mouseover(function(){
document.getElementById('imgid').src="img/large.png";
return false;
});
$("#imgid").mouseout(function(){
document.getElementById('imgid').src="img/little.png";
return false;
});