Back to list
Views:   3.4K
Replies:  0
Archived

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?
 
Jacob Tanner, Feb 20, 2013


Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.3.0