Advanced title, simple question:
How to do the following in jQuery:
$("table tr").click(function() {
$("table tr:not(" + $(this) + ")").hide();
// $(this) is only to illustrate my problem
$("table tr").show();
});
Thanks in advance!
Advanced title, simple question:
How to do the following in jQuery:
$("table tr").click(function() {
$("table tr:not(" + $(this) + ")").hide();
// $(this) is only to illustrate my problem
$("table tr").show();
});
Thanks in advance!
I think a solution can be this:
$("table.tr").click(function() {
$("table.tr:not(" + $(this).attr("id") + "").hide(); // $(this) is only to illustrate my problem
$(this).show();
})
--EDIT for Comment:
$("table.tr").click(function() {
$("table.tr:not(#" + $(this).attr("id") + ")").hide(); // $(this) is only to illustrate my problem
$(this).show();
})
$("table.tr").not(this).hide();
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.