tags:

views:

225

answers:

4

I have a table such as this

            <table class="headerTable" id="headerTable">
                <tbody>
                    <tr class="hh">
                        <td>test1</td>
                        <td>18,164</td>
                    </tr>
                    <tr class="member">
                        <td>test3</td>
                        <td>24,343</td>
                    </tr>
                </tbody>
            </table>

I want to hide the rows with class member.

I did something like this but it is not working..

$("#headerTable tbody tr:member").hide();
+12  A: 

Try this

$("#headerTable tbody tr.member").hide();

The selectors in jQuery like CSS selectors, so you should be able to use them like that.

You can browse the jQuery selector documentation here, it's full of interesting things you can do.

Ólafur Waage
any good place to read about these shorthands?
Added .
Ólafur Waage
+1  A: 

$("#headerTable .member").hide();

Elzo Valugi
+3  A: 

To specify a class using CSS use a dot to signify that it's a class, not a colon. The colon is used by jQuery for filters.

$("tr.member").hide();

Is just fine unless you want to be specific to a table.

altCognito
Could I encourage you to upvote Olafur's response since you both provided the same solution, but he was first?
Jonathan Sampson
He could have been writing his answer while I was writing mine.
Ólafur Waage
I leave it alone unless it's significantly different in some way, say it's more detailed. For instance, I upvoted the other answer on this question: http://stackoverflow.com/questions/1049326/php-error-reporting-on-specific-folders
altCognito
I am curious about others approach as well. Joel or Jeff has suggested that high rep users tend to vote things up more often than non-high-rep users (which isn't surprising as they tend to just be more active in general) - and I do find myself running out of votes after a while, but I do try to let nature take it's course on questions I am answering.
altCognito
Anyway, I have to censor, cause these comments belong on uservoice ;)
altCognito
What I see happening also is the top question getting voted up much more regardless of the quality of answer 2 through n. 2 through n get votes of course but the top answer often gets 2-3x the votes.
Ólafur Waage
Ólafur has the answer and it's succinct, and now quite informative. However, this answer outlines the *problem* that the user had, does it clearly, and for that reason deserves a +1.
ijw
+1  A: 

You could also use find.

$('#headerTable').find('.member').hide();

Or if all the rows (elements, actually) with class member should be hidden:

$('.member').hide();

should work.

tvanfosson