Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
一个有趣的问题,我在一个选择元素上做一个 .clone() (用于预览目的)并且选择的值没有被传输。即我的解决方案是在选择框更改时设置 selected="selected" 。
但是,我无法让它以任何形式工作。想法?
$("select").change( function() { $(this).find("option:selected").attr("selected", "selected"); });
$(this).find("option:selected").attr("selected", "selected");您正在寻找selected然后将其更改为selected?嗯,这没有意义;)
$(this).find("option:selected").attr("selected", "selected");
selected
试试这样的东西怎么样,$(this).find("option").eq(1).attr("selected", "selected");。这将使第二option selected
$(this).find("option").eq(1).attr("selected", "selected");
option