如何使用id ='test'遍历表并使用JQuery获取表中每行的id? 我需要在数组中收集ID。
答案 0 :(得分:3)
我认为您正在寻找jQuery.map
:
var ids = $('table#test tr').map(function() {
return this.id;
});
答案 1 :(得分:1)
var arr = [];
$('#test tr').each(function(){
arr.push($(this).attr('id'));
});
答案 2 :(得分:0)
$('table#test tr').each(function() {
alert($(this).attr('id')); //here you can push these id's into an array
});
答案 3 :(得分:0)
使用此代码:
$("#test tr").each(function(){
var row_id=$(this).attr("id");
// Now do something with the row_id variable.
});
广告@米
答案 4 :(得分:0)
var TrIds = [];
$('#TableId tr').each(function() {
TrIds[] = $(this).id();
});