How do I clear the dropdownlist values on button click event using jQuery?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
A shorter alternative to the first solution given by Russ Cam would be:
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.
or to do it by the index of the option, you could do:
That will remove all
<option>
elements underneath the dropdown element.If you want to unselect selected items, go with the code from Russ.
If you want to reset bootstrap page with button click using jQuery :
Using above code you also have change the field colour as red to normal.
If you want to reset only fielded value then :
If you want to reset the selected options
If you actually want to remove the options (although I don't think you mean this).
Substitute
select
for the most appropriate selector in your case (this may be by id or by CSS class). Using as is will reset all<select>
elements on the page