Advanced title, simple question:
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();
});
As an aside, I think you mean
$("table tr")
(with a space instead of a dot).The way you have it, it selects every table which has a class of
tr
(eg,<table class="tr">
), which is probably not what you want.For more information, see the documentation.
Traversing/Siblings
I think a solution can be this:
--EDIT for Comment:
If you want to combine not() with some other selectors, you can use add():
This would fadeout all other links, but the clicked one, and additionally fadeout some chosen ids and classes.