2013-04-21 72 views
1

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

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

回答

2

你只需要做到这一点 -

$('.delete').click(function() { 
    $(this).next('.warning').fadeIn('slow'); 
}); 
+0

非常感谢穆罕默德! – ewing1990 2013-04-21 12:17:08