3 回答 3

2

尝试这个,

现场演示

idofTr = $(this).closest('tr').attr('id');
于 2012-11-15T16:41:52.473 回答
0

可以用这个

$(this).closest('tr')[0].id  // DOM Object 

使用.closest()

$(this).closest('tr').attr('id');  // jQuery Object
于 2012-11-15T16:44:18.363 回答
0

HTML:

<a onclick="fun1.call(this,1)"></a>

脚本:

function fun1(val){
   var trId = this.parentNode.parentNode.id;
}

顺便说一句,如果不需要避免资源浪费,请不要使用 JQuery。

于 2012-11-15T16:45:18.007 回答