1

我正在努力解决一个我无法处理的问题,我有一个包含数据库记录的表,它是通过 while 循环创建的,所以它们看起来都一样。问题是一个简单的 .delete 单击然后 .warning 淡入函数将出现所有具有相同类的 div,但我需要一个只出现一个 div 的代码。希望你明白。

HTML 代码:

<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');
});
4

1 回答 1

2

你只需要这样做 -

$('.delete').click(function() {
    $(this).next('.warning').fadeIn('slow');
});
于 2013-04-21T11:58:11.837 回答