尝试使用Jquery将img src更改为data-other-src。我们不能用.not()吗?
实现Jquery的:
$('.listItem').not(this).attr({src:$(this).attr("data-other-src")});
HTML(有很多链接):
<a href="#" class="listItem"><img src="../img/updown.png" class="previewImg" data-other-src="../img/here.png"/></a>
答案 0 :(得分:1)
src
和data-other-src
属性位于img
,而不是.listItem
,因此您需要使用.child()
来访问img
$('.listItem').not(this).children("img").attr('src', $(this).children("img").data("other-src"));
答案 1 :(得分:0)
尝试以下操作,在not()
$('.listItem').not($(this)).attr( 'src' ,$(this).attr("data-other-src"));