我正在努力解决一个我无法处理的问题,我有一个包含数据库记录的表,它是通过while循环创建的,所以它们看起来都一样。问题是简单的.delete点击然后.warning fadein函数将出现所有具有相同类的div,但我需要一个只显示一个div的代码。希望你能理解。
HTML code:
<td>
<img class='delete' title='Delete Row' alt=\"Delete\" src='css/images/delete.png'/>
<div class='warning'>Are you sure you want to delete this record ?<br/>
<a id='yes' href=\"delete_client.php?column1=".$row['client_id']."\">Yes</a>
<a id='no'>No</a>
</div>
</td>
<br/>
<td>
<img class='delete' title='Delete Row' alt=\"Delete\" src='css/images/delete.png'/>
<div class='warning'>Are you sure you want to delete this record ?<br/>
<a id='yes' href=\"delete_client.php?column1=".$row['client_id']."\">Yes</a>
<a id='no'>No</a>
</div>
</td>
<br/>
<td>
<img class='delete' title='Delete Row' alt=\"Delete\" src='css/images/delete.png'/>
<div class='warning'>Are you sure you want to delete this record ?<br/>
<a id='yes' href=\"delete_client.php?column1=".$row['client_id']."\">Yes</a>
<a id='no'>No</a>
</div>
</td>
我尝试了这个jQuery代码,但它似乎没有用,因为没有出现。
$('.delete').click(function() {
$(this).parent().next('.warning').fadeIn('slow');
});
答案 0 :(得分:2)
你只需要这样做 -
$('.delete').click(function() {
$(this).next('.warning').fadeIn('slow');
});