Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to "reset" a combobox using jquery

i have a select dropdown on a webpage:

<select class="designs" id="color" name="Color">
 <option value="">Select Color . . .</option>
 <option value="Dark">Dark</option>
 <option value="White">White</option>
 <option value="Light">Light</option>
</select>

and i am trying to find the right jquery code to select the first entry on that combobox (the one with option value ="" and the text of "Select Color . . ." (this is the setting that is on the page during original load before the user makes any changes)

I am doing this off of a button click link that says "Reset".

like image 797
leora Avatar asked Oct 15 '11 18:10

leora


1 Answers

You could use the .val() function. And because the value of the element you want to preselect is empty you pass an empty string:

$('#color').val('');
like image 61
Darin Dimitrov Avatar answered Sep 28 '22 09:09

Darin Dimitrov