Add the "selected" attribute to a drop down option with jQuery
<p>How do I add the attribute "selected" to a drop down menu option based on that option matching some variable?</p>

<p>Here is how the dropdown is populated...</p>

<pre><code>loginOptions = ["First", "Second", "Third"];
        var Login = $( '#Login' );

        for ( var i = 0; i &lt; loginOptions.length; i++ ) {
            Login.append('&lt;option value="'+ loginOptions[i] +'"&gt;'+             loginOptions[i] +'&lt;/option&gt;');
        }
</code></pre>

<p>I want to mark one option as "selected" based on whether or not its value matches another variable. so if <code>loginOption[i]</code> is equal to <code>var existingLoginValue</code> then set that option to 'selected'</p>

<p>Something that would do</p>

<pre><code>if(loginOptions[i] === existingLoginValue){ print 'selected'; };
</code></pre>

<p>Thanks!</p>
