如何使用jquery的each函数对动态生成的列表进行遍历

html代码:


<div id="companyContent"></div>

这个div里面有一个js动态生成的tbody表格以及若干个tr,每个tr里面有若干个td单元格,现在我想取每个tr下面的第七个td标签的title值,用常规的each的方法却无效,请问正确的写法是什么,贴上我的jquery代码

$('#companyContent').on('each','tbody tr td:nth-child(7)',function () {

            var cc=$(this).attr('title');

            if(cc=='审核通过'){

                $(this).parent().find('td').last().find('input').eq(0).val('查看');

                $(this).parent().find('td').last().find('input').eq(0).attr('onclick','ang(this)');

            }

        });


尚方宝剑之说
浏览 599回答 1
1回答

慕村9548890

当table存在时:$('#companyContent').find('tbody tr').each(function(){&nbsp; &nbsp; var title = $(this).children('td').eq(6).attr('title')&nbsp; &nbsp; &nbsp;if(title == '审核通过'){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;...&nbsp; &nbsp; &nbsp;}})
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript