Ale*_*eau 0 jquery jquery-selectors
当我将鼠标悬停在它上面时,我试图在html行中选择一个链接,我可能做错了.
这是我的HTML:
<table id="table-id">
<tr>
<td>yeah</td>
<td>some content</td>
<td><a href="#" class="remove">delete</a></td>
</tr>
...
</table>
Run Code Online (Sandbox Code Playgroud)
和jQuery代码:
$('#table-id tr').hover(function(){
$(this).children('.remove').show(); # I don't get the link in there
}, function(){
$(this).children('.remove').hide(); # and thus not here neither
});
Run Code Online (Sandbox Code Playgroud)
这些链接隐藏在:
$('a.remove').each(function(){
$(this).hide();
$(this).click(function(){
return confirm("are you sure?");
});
});
Run Code Online (Sandbox Code Playgroud)
关于我在这里缺少什么的想法?
直接的孩子tr是td元素,因此它不起作用.你可以使用这样的东西:
$('#table-id tr').hover(function(){
$(this).children().find(".remove").show();
}, function(){
$(this).children().find(".remove").hide();
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2385 次 |
| 最近记录: |