I have a table with rows that have the of custom attribute with each other. I want to hide all the table rows except for the parent row using jQuery (or Javascript). How can I go by doing this?
<table>
<tr group="1">Parent</tr>
<tr group="1">Child</tr>
<tr group="1">Child</tr>
<tr group="1">Child</tr>
</table>
Edit: Wow big typo on my part, I am terribly sorry, I meant custom attribute. Updated!
With your new example, it’s possible using jQuery’s
atribute equalsselector (here). Take a look at this tasty fiddle.Basically, in your selector, you need this:
$("table tr[group='2']").hide()Of course, this is customisable. The important bit is
tr[group='2']EDIT
This updated fiddle should work. If someone can post a better way, please do.
It adds to the above line with this:
$("table tr[group='2']").filter(":not(:first)").hide();