Jquery:FAQ风格
我有以下资料:Jquery:FAQ风格,jquery,Jquery,我有以下资料: <table class="site"> <tr> <td> <span style="float: right;" class='show'>Show More</span> </td> </tr> <tr class="site_info"> <td><%= site.id %></td> </tr&g
<table class="site">
<tr>
<td>
<span style="float: right;" class='show'>Show More</span>
</td>
</tr>
<tr class="site_info">
<td><%= site.id %></td>
</tr>
<tr>
<td align='right'>
More
</td>
</tr>
</table>
我似乎无法找到/选择站点信息部分。find命令只搜索当前元素的后代
$('.site_info').hide().css('cursor', 'pointer');
$('.show').click(function() {
$('.site_info').show("slow");
});
试试这个
$(this).parents("table").find(".site-info").slideToggle();
find
搜索“子代”,不要与子代
混淆。如果有嵌套表(尽管希望没有),也应该使用最近的
而不是父代
。
$(this).parents("table").find(".site-info").slideToggle();
$('.site_info').hide().css('cursor', 'pointer');
$('.show').click(function() {
$(this).parents( "table" ).find('.site_info').show( "slideToggle" );
});
$(".site_info").hide().css("cursor", "pointer");
$(".show").click(function() {
$(this).closest("table.site").find("tr.site_info").slideToggle();
});