
<table>
<tr><td>行1列1</td><td>行1列2</td><td>行1列3</td></tr>
<tr><td>行2列1</td><td>行2列2</td><td>行2列3</td></tr>
</table>
来个点击的
$("table tr")click(function()
{
var $this = $(this);
//$this就是这个行,你点哪行,哪行就有反应。
})
html:
<td id="ctId" onclick="test(this)">ctId</td>
js:
function test(obj){
var v = $(obj)html();
alert(v);
}
可以用jQ的index()方法,举例:
<table id="table1"><tr>
<td>第1行</td>
</tr>
<tr>
<td>第2行</td>
</tr>
<tr>
<td>第3行</td>
</tr>
<tr>
<td>第4行</td>
</tr>
</table>$('#table1')find('tr')click(function() {
var idx = $(this)index() + 1; // 索引是从0开始的,故+1
consolelog('点击了第' + idx + '行');
});
以上就是关于用jquery 得到选择table 某一行的数据、全部的内容,包括:用jquery 得到选择table 某一行的数据、、jquery获取表格选中行的值、jquery如何获取取元素序号,例如一个有N行的table,点击其中的一行,获取到它的行号。等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)