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/

Published by

Konrad Fedorczyk

Konrad Fedorczyk

I'm interested in programming and gamedev. I especially luv HTML5 and everything connected to web technologies.

Leave a Reply

Your email address will not be published. Required fields are marked *