在jQuery选择器中通过:not隐藏$(this)以外的所有内容 [英] Hide all but $(this) via :not in jQuery selector

查看:595
本文介绍了在jQuery选择器中通过:not隐藏$(this)以外的所有内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

高级标题,简单的问题:

Advanced title, simple question:

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

How can I do the following in jQuery (hiding everything except $(this))?

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

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

推荐答案

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

遍历/兄弟姐妹

这篇关于在jQuery选择器中通过:not隐藏$(this)以外的所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆