Blankman
Blankman

Reputation: 266940

How can I show and hide a table row using jQuery?

I have a regular HTML table, how can I show and hide a table row using jQuery?

Upvotes: 1

Views: 1839

Answers (5)

redsquare
redsquare

Reputation: 78667

I would steer clear of the show and hide methods for table rows. They lead to bad ui effects x-browser. I have found fadeIn/Out to work much better x-browser.

Upvotes: 0

Boushley
Boushley

Reputation: 7036

Also, you might want to look at the .toggle() function.

$('tr:nth(5)).toggle()

This will show/hide it and continually switch...

Upvotes: 1

cgp
cgp

Reputation: 41381

Hides every 5th row:

$('tr:nth(5)).hide()

An example: http://jsbin.com/epeto

Upvotes: 4

Colin Brock
Colin Brock

Reputation: 21565

Just to add to Nuno's answer above, JQuery's toggle() function may also be useful to you

Upvotes: 0

Nuno Furtado
Nuno Furtado

Reputation: 4568

Either iterate the tr elements inside your table or add id's to your trs and calling the show/hide function in jQuery with that ID

Upvotes: 1

Related Questions