所以我正在尝试创建一个带有类“delete”父 tr 元素的淡出效果。
这是我的 jsfiddle,您可以在其中实时查看它 - http://jsfiddle.net/syTXZ/
代码在这里-
HTML -
<table border="1px solid black">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Parent</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<tr>
<td>2</td>
<td>test222</td>
<td>test2</td>
<td><a href="#" categoryID="1" class="edit">Edit Category</a></td>
<td><a href="#" categoryID="1" class="delete">Delete Category</a></td>
</tr>
<tr>
<td>1</td>
<td>te1t22</td>
<td>tes1t</td>
<td><a href="#" categoryID="1" class="edit">Edit Category</a></td>
<td><a href="#" categoryID="1" class="delete">Delete Category</a></td>
</tr>
<tr>
<td>3</td>
<td>test2</td>
<td>test</td>
<td><a href="#" categoryID="1" class="edit">Edit Category</a></td>
<td><a href="#" categoryID="1" class="delete">Delete Category</a></td>
</tr>
</tbody>
</table>
和 js -
$("a.delete").click(function() {
$(this).parents("tr").fadeOut(300);
}
但是它不起作用,有什么线索吗?我也尝试了 parent() 而不是 parents(),但它也没有用。
最佳答案
更新修复:jsFiddle
你错过了 );
$("a.delete").click(function() {
$(this).parents("tr").fadeOut(300);
}
应该是
$("a.delete").click(function() {
$(this).parents("tr").fadeOut(300);
});
关于javascript - jQuery parents ("tr") 淡出不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11806928/