我正在尝试从每个节点中删除默认值。我尝试了以下代码
$( document ).ready(function() {
$( "table tbody tr td:nth-of-type(1) select option").first().remove();
});
它从第一个节点中删除了元素。有人可以帮我从每个节点中删除第一个元素。
我正在尝试从每个节点中删除默认值。我尝试了以下代码
$( document ).ready(function() {
$( "table tbody tr td:nth-of-type(1) select option").first().remove();
});
它从第一个节点中删除了元素。有人可以帮我从每个节点中删除第一个元素。
$("table tbody tr td:nth-of-type(1) select option:first-child").remove();
.first()
returns the first element in the set.
You want to use the :first-child
selector, which will filter the simple selector you apply it to to only match the first child of the parent:
$("table tbody tr td:first-child select option:first-child")
This will only match <option>
elements that are the first child of their respective parents.
You can also use it on the td
.