How to set the ‘selected option’ of a select dropdown list with jquery

0
616

Try this :

$('select[name^="salesrep"] option[value="Bruce Jones"]').attr("selected","selected");

Just replace option[value="Bruce Jones"] by option[value=result[0]]

And before selecting a new option, you might want to “unselect” the previous :

$('select[name^="salesrep"] option:selected').attr("selected",null);

You may want to read this too : jQuery get specific option tag text

Edit: Using jQuery Mobile, this link may provide a good solution : jquery mobile – set select/option values

Reference Link – https://stackoverflow.com/questions/17856523/how-to-set-the-selected-option-of-a-select-dropdown-list-with-jquery

LEAVE A REPLY

Please enter your comment!
Please enter your name here