利用data-src属性 更换图片

时间:2024-06-15 19:38:14

<div class="img_src"> <img src="./images/luo.png"></div>

<ul class="ul_div">

<li class="current" data-src="./images/tihuan1.png">1</li>

<li data-src="./images/tihuan2.png">2</li>

<li data-src="./images/tihuan3.png">3</li>

</ul>

var img_dom = $('.left img');
$('.show_lo').mouseover(function() {
$(this).addClass("current").siblings().removeClass("current");
img_dom.attr('src', this.getAttribute('data-src'));
});