如何使用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'标签。它应该在'