高级标题,简单问题:
如何在jQuery中执行以下操作(隐藏除$(this)
之外的所有内容)?
$("table tr").click(function() {
$("table tr:not(" + $(this) + ")").hide();
// $(this) is only to illustrate my problem
$("table tr").show();
});
发布于 2009-08-25 13:37:18
$(this).siblings().hide();
发布于 2014-02-07 20:50:55
如果您想将not()与其他一些选择器结合使用,您可以使用add():
$('a').click(function(e){
$('a').not(this).add('#someID, .someClass, #someOtherID').animate({'opacity':0}, 800);
});
这将淡出所有其他链接,但单击的链接除外,并另外淡出一些选定的ids和类。
发布于 2009-08-25 13:48:33
我认为解决方案可以是这样的:
$("table.tr").click(function() {
$("table.tr:not(" + $(this).attr("id") + "").hide(); // $(this) is only to illustrate my problem
$(this).show();
})
--编辑备注:
$("table.tr").click(function() {
$("table.tr:not(#" + $(this).attr("id") + ")").hide(); // $(this) is only to illustrate my problem
$(this).show();
})
https://stackoverflow.com/questions/1328314
复制相似问题