编辑,因为我仍然收到错误:
我有一个文本框,它动态添加到外部javascript文件中的Jquery数据表中。
"checked"属性始终返回未定义,即使它默认为选中也是如此。
$('#Table tbody tr').each(function () {
console.log($(this).children().eq(5).html(), $(this).children().eq(5).prop('checked'));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<td><input type="checkbox" checked class="profiles-checkboxes" /></td>
当检查输入以开头时,返回以下内容:
<input type="checkbox" checked="" class="profiles-checkboxes"> undefined
$(this).children().eq(5)
是没有checked
属性的<td>
。您需要从里面的<input>
获取属性。
$(this).children().eq(5).children(":checkbox").prop("checked")