如果我使用以下html下拉菜单:
<select id="myDropdown" name="myDropdown">
<option value="6">Six</option>
<option value="5">Five</option>
<option value="3">Three</option>
<option value="1">One</option>
</select>
单击按钮后,如何将此下拉列表更改为特定的选定值?
最佳答案
如果您的按钮是id =“ myButton”,则可以这样操作:
原文链接:https://www.f2er.com/html/530644.html$("#myButton").click(function() {
$("#myDropdown").val(1); //1 being whatever value you want to set
});