类似页面如下:
实际使用.closest() 和 .find()更合适
当然也可以
如果,有多行的话用.delegate()如下:
<tr>
<td><input type="checkbox" class="chk" /></td>
<td><div class="disabled">text to hide 1</div></td>
<td><div class="disabled">text to hide 2</div></td>
</tr>
$("input.chk").click(function(){
$(this).parent().parent().(".disabled").show();
}) ;
实际使用.closest() 和 .find()更合适
$("input.chk").click(function(){
$(this).closest('tr').find(".disabled").show();
});
当然也可以
$(this).parent().parent().find(".disabled").show();
如果,有多行的话用.delegate()如下:
$("table").delegate("input.chk", "click", function(){
$(this).closest('tr').find(".disabled").show();
});
#.delegate() instead binds one handler to the table for all of the input.chk elements to bubble up to. If you're looking to enable/disable, use hcnage and .toggle() in addition to the above, like this:
$("table").delegate("input.chk", "change", function(){
$(this).closest('tr').find(".disabled").toggle(this.checked);
});