How to programmatically select option in a HTML list using jQuery?

This is very simple solution to select specified option in a HTML select list.

You just need to use the val function on a select element to set it’s value. It’s simple like that:

$('select#identificator').val('value of existing option value');

Check working example on the JSFiddle: http://jsfiddle.net/fedek6/B3Ehj/



Tags: