请帮我用jQuery的语法。
1)如何查找的行数/指数在一个HTML表? 生成的表忽略了最低有任何ID为一行。
例如:我有产生一个普通的HTML表格,其中有10行, 我动态添加行到该表中。(在现有行之间)
自从我加入新行,现有行的索引将change.Now我需要找到每一行的索引添加新行之前。
最后,我是新来的jQuery的,请提供一个很好的参考站点的所有jQuery的语法。
感谢
SNA
解决方案1)如何查找的行数/指数在一个HTML表?生成的表忽略了最低有任何ID为行。的
如果你的意思是你已经有了一个排,和你需要它的索引,不使用jQuery来得到它。表行维持通过 rowIndex位置
的所有权属于其自己的索引。
$('表TR)。点击(函数(){
警报(this.rowIndex); //提醒点击行的索引数目。
});
演示:的 http://jsfiddle.net/LsSXy/
please help me with jquery Syntax.
1) How do i find the row number/index in a HTML table? The generated table dosen't have any id for row.
eg: i have a plain HTML table generated, which has 10 rows, i am adding rows dynamically to this table.(in between existing rows)
since i am adding new row, the existing row index will change.Now i need to to find the index of each row before adding the new row.
Last, I am new to Jquery ,please suggest a good reference site for all Jquery Syntaxes.
Thanks
SNA
解决方案"1) How do i find the row number/index in a HTML table? The generated table dosen't have any id for row."
If you mean that you already have a row, and you need its index, don't use jQuery to get it. Table rows maintain their own index via the rowIndex
property.
$('table tr').click(function() {
alert( this.rowIndex ); // alert the index number of the clicked row.
});
Demo: http://jsfiddle.net/LsSXy/