作者:_Terr1鄭x宜_F | 来源:互联网 | 2023-01-30 10:54
Thecodebelowworkingforonlyfirstdiv.Icantdisplayotherdivswheniclickedontheotheri
The code below working for only first div. I can't display other divs when i clicked on the other "img"s. Do you know a method to reach second (next) element?
以下代码仅适用于第一个div。当我点击其他“img”时,我无法显示其他div。你知道一种方法来达到第二个(下一个)元素吗?
$(document).ready(function() {
$('.imgOpenClose').click(function() {
if ($(this).attr("src") == "images/openTree.gif") {
$(this).attr("src", "images/closeTree.gif");
$(this).parent().find('div').eq(0).show();
}
else {
$(this).attr("src", "images/openTree.gif");
$(this).parent().find('div').eq(0).hide();
}
});
});
2 个解决方案