Reality-Torrent Reality-Torrent - 6 months ago 51
HTML Question

Hide <tr> based on ID

I have a page consisting of several

elements and each
element has several
tags. These
tags are added dynamically but all get a unique ID.

Now when the user picks a certain value from a dropdownbox I want to hide all the
tags that does not match the users choice.

This allows me to get the ID of the option the user has chosen.

$('#groupDropDownBox option:selected').attr('id');

And this selects all the
tags inside the

$('#reviewGroupsDiv tr')

Now how would I go about hiding all
tags that does now have the ID that the user has selected?

Appreciate any assistance!


If you want to hide the <tr> with the selected ID, you simply select it by its id:


If you want to hide everything BUT the selected ID, you can use the jQuery .not() selector to select all elements from a certain type without the one that has your desired ID: