搜索上级dom对象并隐藏,点击隐藏父元素
发布日期:2021-09-29 20:08:49 浏览次数:5 分类:技术文章

本文共 793 字,大约阅读时间需要 2 分钟。

类似页面如下:
      
text to hide 1
text to hide 2
$("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); });

转载地址:https://blog.csdn.net/horace_lee/article/details/83924438 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Rails 3 的active record和其他
下一篇:关于router restful和button_to

发表评论

最新留言

关注你微信了!
[***.104.42.241]2024年04月03日 11时06分33秒