jquery - 通过 :not in jQuery selector 隐藏除 $(this) 之外的所有内容

标签 jquery jquery-selectors this

进阶题目,简单问题:

我如何在 jQuery 中执行以下操作(隐藏除 $(this) 之外的所有内容)?

$("table tr").click(function() {
    $("table tr:not(" + $(this) + ")").hide();
    // $(this) is only to illustrate my problem

    $("table tr").show();
});

最佳答案

$(this).siblings().hide();

Traversing/Siblings

关于jquery - 通过 :not in jQuery selector 隐藏除 $(this) 之外的所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1328314/

相关文章:

AJAX 调用后 jQuery 绑定(bind)点击链接

javascript - 如何使 jQuery 构造函数属性全局可见

javascript - jQuery 选择器 : all but n first in a row

android - 为什么在此代码中使用this @ MainActivity?

c++ - 隐式对象参数和 this 指针

jquery - 用 Fancybox 2 制作 "Facebook Photo Viewer"

javascript - JQUERY - 自调整导航

jQuery <div> 内容交换脚本不适用于 IE7 和 IE8

jquery - 使用 jQuery 选择 xml 子元素

jquery - 棘手的突出显示旋转 JQuery - 计时器和选择器