如何清除使用jQuery按钮单击事件DropDownList的值? [英] How do I clear the dropdownlist values on button click event using jQuery?
本文介绍了如何清除使用jQuery按钮单击事件DropDownList的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何清除使用jQuery按钮单击事件DropDownList的值?
How do I clear the dropdownlist values on button click event using jQuery?
推荐答案
一个较短的替代给出的第一个解决方案的拉斯凸轮是:
A shorter alternative to the first solution given by Russ Cam would be:
$('#mySelect').val('');
此假设要保留之列,但让这个没有选项被选中。
This assumes you want to retain the list, but make it so that no option is selected.
如果你想选择一个特定的默认值,只是传递价值,而不是一个空字符串。
If you wish to select a particular default value, just pass that value instead of an empty string.
$('#mySelect').val('someDefaultValue');
或期权的指数做到这一点,你可以做:
or to do it by the index of the option, you could do:
$('#mySelect option:eq(0)').attr('selected','selected'); // Select first option
这篇关于如何清除使用jQuery按钮单击事件DropDownList的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文