I have a regular HTML table, how can I show and hide a table row using jQuery?
我有一个常规的HTML表,如何使用jQuery显示和隐藏表行?
5 个解决方案
#1
Hides every 5th row:
每隔5行隐藏:
$('tr:nth(5)).hide()
An example: http://jsbin.com/epeto
一个例子:http://jsbin.com/epeto
#2
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
迭代表中的tr元素或将id添加到你的trs并使用该ID调用jQuery中的show / hide函数
#3
Also, you might want to look at the .toggle() function.
此外,您可能希望查看.toggle()函数。
$('tr:nth(5)).toggle()
This will show/hide it and continually switch...
这将显示/隐藏它并不断切换......
#4
Just to add to Nuno's answer above, JQuery's toggle() function may also be useful to you
只是为了添加上面Nuno的答案,JQuery的toggle()函数对你也很有用
#5
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.
我会避开show并隐藏表行的方法。它们导致x-browser的糟糕ui效果。我发现fadeIn / Out可以更好地运行x-browser。
#1
Hides every 5th row:
每隔5行隐藏:
$('tr:nth(5)).hide()
An example: http://jsbin.com/epeto
一个例子:http://jsbin.com/epeto
#2
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
迭代表中的tr元素或将id添加到你的trs并使用该ID调用jQuery中的show / hide函数
#3
Also, you might want to look at the .toggle() function.
此外,您可能希望查看.toggle()函数。
$('tr:nth(5)).toggle()
This will show/hide it and continually switch...
这将显示/隐藏它并不断切换......
#4
Just to add to Nuno's answer above, JQuery's toggle() function may also be useful to you
只是为了添加上面Nuno的答案,JQuery的toggle()函数对你也很有用
#5
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.
我会避开show并隐藏表行的方法。它们导致x-browser的糟糕ui效果。我发现fadeIn / Out可以更好地运行x-browser。