Dofactory.com
Dofactory.com
 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     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.