我有JS函数,它通过表解析:
// id contains a message id, activeRow is "this" from onClick on tr
function doSomething ( id, activeRow ) {
// AJAX calling using id as parameter
$("#searchResultTable > tbody > tr").each(function(index) {
$(this).removeClass("bold");
});
}
Run Code Online (Sandbox Code Playgroud)
这非常合适(感谢Ariel @ 其他帖子),但我认为应该有另一种可能性,例如:
var table = $(activeRow).parent();
$("tbody > tr", table).each(function(index) {
// .. do something
});
// The above clearly doesn't work, but should document what I'm looking for.
Run Code Online (Sandbox Code Playgroud)
这将允许使用相同的表ID,而函数将分别对它们中的每一个起作用.
非常感谢!
jQuery的parents()方法使得父表变得简单:
$(activeRow).parents('table')[0];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9366 次 |
| 最近记录: |