tags:

views:

51

answers:

2

Hello,

i have multiple rows with the same id and when used the jquery function :

hide();

it hide the first row only and ignore the rest rows.

Could you please tell how can i fix it ?

Thanks in Advance

Neveen

+6  A: 
T.J. Crowder
Thanks a lot T.J. Crowder , the rows has common class how can i use it to hide them?? Thnaks
Neveen
@Neveen: I've put an example in the answer.
T.J. Crowder
A: 

T.J Crowder above is correct.

Another thing you may find useful in jQuery is the each() function.

$('tr.foo').each(
    function(object){
        // do more stuff
        object.hide();
    }
);

With that, you can apply conditional logic as well, maybe only hide the row if it's content contains a filter-word or something.

I didn't actually know that I didn't have to use the 'each'. (thanks TJ)

Alex C
@Alex C: You're welcome. :-) But actually, the above is incorrect. The first parameter that jQuery passes its `each` function (http://api.jquery.com/each/) is the *index* of the item. It sets `this` to point to the DOM element for that iteration (and also passes it as the second parameter, in case you've used `proxy` (http://api.jquery.com/jQuery.proxy/) to set `this` to something else in the iterator function).
T.J. Crowder