我有一些行和列的 HTMLTable。单击时,我将函数绑定(bind)到此表的单元格。在此函数中,我需要获取所选行中第一个单元格的值。 我有以下内容:
$(this).parent().children()
gives me object with 4 HTMLTableCellElement like on the picture
我需要获取包含 [0] 元素的 innerHTML 的文本:
如何获取这段文字?
If I use $(this).parent().children('0').innerHTML it gives me "undefined"
最佳答案
.children()
返回一个 DOM 元素数组。您可以简单地获取数组中的第一个元素:
$(this).parent().children()[0].innerHTML
关于javascript - 如何使用 jQuery 获取 Object 集合的子元素的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19913337/