Reset button on form doesn't reset selection for first element due to selected keyword in HTML

I have a reset button on a form

<input type="reset" value="Reset">

      

and some elections

<select>
<option value="0">A</option>
<option value="10" selected="selected">B</option>
</select>

      

If I click on reset, nothing happens. Here's an example.

Edit: I thought the button would reset to the first value of the select list. It seems that it was a misunderstanding of my side. I want to reset to the first selection item.

So, the only way to create a reset function in Javascript? What if the user has disabled Javascript?

+3


source to share


2 answers


Force value for all inputs, selections, etc.



$("#filter_form").find("select, input, checkbox").val("");

      

+3


source


When I press the reset button, we form the default reset. It works in your example (option 10 by default).



+2


source







All Articles