这个是javascript的写法

<img src="res/img/shop-c_32.jpg" alt="" onmouseover="this.src='res/img/shop-c_29.jpg';" onmouseout="this.src='res/img/shop-c_32.jpg';">

这是个jquery的写法

<img src="res/img/shop-c_32.jpg" data-back="res/img/shop-c_29.jpg">

再加上jquery的效果写法

<script>
$("img[data-back]").hover(function(){
    $(this).data('fallback',$(this).attr('src'));
    $(this).attr('src',$(this).data('back'));
},function(){
    $(this).attr('src',$(this).data('fallback'));
});

</script>

我比较倾向于后者的写法。那大家觉得呢?

相关文章:

  • 2022-12-23
  • 2021-06-08
  • 2022-12-23
  • 2021-09-11
  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-15
相关资源
相似解决方案