jQuery的语法查找行索引的HTML表格 [英] Jquery syntax for finding row index in a html table

查看:176
本文介绍了jQuery的语法查找行索引的HTML表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮我用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/

这篇关于jQuery的语法查找行索引的HTML表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆