1
为什么select
中有optgroups时不工作?选项:第一个孩子在所有情况下都没有选择相同
不起作用
$("option:first-child").attr("selected", "selected");
工作
$("select>option:first-child").attr("selected", "selected");
当我做$("select:eq(1) option:first-child").val()
这似乎是获得正确的option
,但是当我打电话attr()
它没有选择正确的一个。
精氨酸!我知道'val()'返回第一个值。大脑放屁告诉我,.attr(“选定”)也是设置第一个的值。愚蠢的屁。谢谢! – Homer