Home  /  Questions  /  Question



72   96.1
Feb 20, 2013


Setting the selected attribute on a select list in jQuery

I have the following scenario and want to be able to quickly set one of the items as selected, like so: 
<select id="cities">
    <option>London</option>
    <option>Brighton</option>
    <option>Birmingham</option>
</select>
to
<select id="cities">
    <option>London</option>
    <option>Brighton</option>
    <option selected="selected">Birmingham</option>
</select>
How is this done using jQuery?