Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To select the first option in a select list, try looking at jQuery's <a href="http://api.jquery.com/first/" rel="nofollow">.first()</a></p> <pre><code>var first = $('select option').first(); </code></pre> <p>To select the selected option in a select list, try looking at jQuery's <a href="http://api.jquery.com/selected-selector/" rel="nofollow">:selected Selector</a></p> <pre><code>var selected = $('select option:selected'); </code></pre> <p>To select the option with a particular attribute, try looking at jQuery's <a href="http://api.jquery.com/attribute-equals-selector/" rel="nofollow">Attribute Equals Selector</a></p> <pre><code>var english = $('select option[lang="English]'); </code></pre> <p>Combining these to get the first English selected element, we get:</p> <pre><code>var engSelected = $('select option[lang="English]:selected') </code></pre> <p><strong>Edit:</strong> It looks like your HTML attributes are not set up correctly, try this:</p> <pre><code>&lt;select id = "selectLanguage" name="language"&gt; &lt;option value="any" lang="English"&gt;All&lt;/option&gt; &lt;option value="any" lang="French"&gt;Tous&lt;/option&gt; &lt;option value="french" lang="English"&gt;French&lt;/option&gt; &lt;option value="french" lang="French"&gt;Français&lt;/option&gt; &lt;option value="english" lang="English"&gt;English&lt;/option&gt; &lt;option value="english" lang="French"&gt;Englais&lt;/option&gt; &lt;/select&gt; </code></pre> <p><strong>Note:</strong></p> <p>You can also refine your selection by attributes, like this:</p> <pre><code>var engEnglish = $('select option[value="english"][lang="English"]'); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload