JQuery setting the selected attribute on a select list
        Posted  
        
            by 
                Rupert
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Rupert
        
        
        
        Published on 2009-08-21T10:55:40Z
        Indexed on 
            2010/12/21
            13:54 UTC
        
        
        Read the original article
        Hit count: 196
        
jQuery
I have the following html
<select id="dropdown">
    <option>A</option>
    <option>B</option>
    <option>C</option>
</select>
I have the string "B" so I want to set the selected attrribute on it so it will be:
<select id="dropdown">
    <option>A</option>
    <option selected="selected">B</option>
    <option>C</option>
</select>
How would I do this in JQuery?
© Stack Overflow or respective owner