搜索上级dom对象并隐藏,点击隐藏父元素
类似页面如下:
<tr> <td><input type="checkbox" /></td> <td><div name="code">$("input.chk").click(function(){ $(this).parent().parent().(".disabled").show();}) ;
$("input.chk").click(function(){ $(this).closest('tr').find(".disabled").show();});
$(this).parent().parent().find(".disabled").show();
$("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);});