如何使用jQuery將類添加到下一張圖片?Jquery將類添加到下一張圖片使用JQuery標記
我已使用循環的網頁圖像。它們顯示在表格行中。
<table class="table table-bordered">
<?php
<td><img class="img1" src="http://s5.tinypic.com/30v0ncn_th.jpg"/></td>
for ($x = 0; $x < 5; $x++) { ?>
<td>
<img class="loopimg" src="http://s5.tinypic.com/30v0ncn_th.jpg"/>
</td>
<?php } ?>
</table>
我想什麼實現的是當我第一次圖像(類=「IMG1」)上單擊,將其添加類下一個圖像,點擊,將添加類下一個圖像。
$('.img1').click(function(){
$(this).parent().next("td").addClass("active");
alert("class");
});
這個jQuery代碼添加「活性」級到下<td>
標籤,我想類被添加到下一個圖像。預先感謝您
[jQuery的學習中心(https://開頭學習.jquery.com) – Andreas
你有一個錯位的<?php'標籤。它應該在'