当我向 Html 表格添加新行时,我想聚焦该行的第一个单元格。
我当前的代码是
$('table td').first().focus(); // focus on the first cell of the row
但这会选择整个表格的第一个单元格。获取添加行的第一个单元格需要什么?
最佳答案
也就是说,“在 table
中查找第一个 td
。”
您想要“在 table
的最后一个 tr
中查找第一个 td
。”
$('table tr').last().find('td').first().focus();
假设最后一个 tr
是刚刚添加的行。
关于javascript - 将第一个元素聚焦在新行上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40360590/