Javascript jquery从表中获取和附加id
我有以下html:Javascript jquery从表中获取和附加id,javascript,jquery,html,Javascript,Jquery,Html,我有以下html: <table class="userenrolment ajaxactive"> <tbody> <tr class="userinforow r0" id="user_9"> <td class="field col_userdetails cell c0" style=""> </td> <td class="field col_enrol cell c4 lastcol" style=""> <
<table class="userenrolment ajaxactive">
<tbody>
<tr class="userinforow r0" id="user_9">
<td class="field col_userdetails cell c0" style="">
</td>
<td class="field col_enrol cell c4 lastcol" style="">
<div class="enrolment"><span>Team 1</span>
</div>
</td>
</tr>
<tr class="userinforow r1" id="user_4">
<td class="field col_userdetails cell c0" style="">
</td>
<td class="field col_enrol cell c4 lastcol" style="">
<div class="enrolment"><span>Team 2</span>
</div>
</td>
</tr>
</tbody>
</table>
第一队
第二小组
使用jQuery,我想从每个tr获取id,并将其附加到同一行
我的函数看起来像这样,但根本不起作用:
function show_groups(){
table.find('.userinforow).each(function(){
var text = $(this).find('#id').val();
$('.enrolment').append('text:' + text + ' <br>');
}
函数显示组(){
table.find('.userinforow).each(函数(){
var text=$(this.find('#id').val();
$('.incorporation').append('text:'+text+'
');
}
您需要
function show_groups() {
$('.userenrolment').find('.userinforow').each(function () {
$(this).find('.enrolment').append('text:' + this.id + ' <br>');
});
}
函数显示组(){
$('.userEnrollment').find('.userinforow').each(函数(){
$(this.find('.incluation').append('text:'+this.id+'
');
});
}
演示:这似乎不起作用。我尝试了:函数show_groups(){table.find('.userinforow')。每个函数({alert(“TEST”);$(This.finder('.inclusion')。append('text:'+This.id+'
'));}),但没有显示警报。@user2075124问题可能是
表
参考,请尝试更新