jQuery从索引中选择行 [英] jquery row selection from index
本文介绍了jQuery从索引中选择行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想给定一个表ID和一个行索引(从0开始),选择该索引处的行,以便可以将背景色应用于所有td.我熟悉基本选择,但是不确定如何使用索引变量来完成此操作.
I want, given a table id and a row index (0-based), to select the row at that index so that I can apply a background color to all of its td's. I'm familiar with basic selection, but am not sure how to do this using an index variable.
推荐答案
这应该为您解决问题:
$('#id tbody > tr').eq(rowindex)
或者,根据您的要求在评论中:
or, per your request in comments:
$('#id tbody > tr').eq(rowindex).children().addClass('myClass');
这篇关于jQuery从索引中选择行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文