jQuery set all select inputs to certain value : <p>I'd like to loop through all of the select inputs on a page and if the selected value is not a certain option then set that value to selected</p>

<p>I have some selects (notice in select1, option 2 is selected)</p>

<pre><code>&lt;select name="select1"&gt;
  &lt;option value="1"&gt;One&lt;/option&gt;
  &lt;option value="2" selected&gt;Two&lt;/option&gt;
  &lt;option value="3"&gt;Three&lt;/option&gt;
  &lt;option value="4"&gt;Four&lt;/option&gt;
  &lt;option value="5"&gt;Five&lt;/option&gt;
&lt;/select&gt;

&lt;select name="select2"&gt;
  &lt;option value="1"&gt;One&lt;/option&gt;
  &lt;option value="2"&gt;Two&lt;/option&gt;
  &lt;option value="3"&gt;Three&lt;/option&gt;
  &lt;option value="4"&gt;Four&lt;/option&gt;
  &lt;option value="5"&gt;Five&lt;/option&gt;
&lt;/select&gt;

&lt;select name="select3"&gt;
  &lt;option value="1"&gt;One&lt;/option&gt;
  &lt;option value="2"&gt;Two&lt;/option&gt;
  &lt;option value="3"&gt;Three&lt;/option&gt;
  &lt;option value="4"&gt;Four&lt;/option&gt;
  &lt;option value="5"&gt;Five&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p>The idea here would be to have a checkbox that when it's checked set select2 and select3 to have option 2 selected as they don't have that option already selected and append a string to the value so I know they've been updated e.g '-updated' </p>

<p>I'm looping through them like so, but I can't figure out how to set the selected property to option '2' if it isn't already selected and then append '-updated' to the value</p>

<pre><code>$('select').each(function() {

    var selected = $(this).find(":selected");

    if (selected.val() != 2) {
        // set option 2 as selected
        // append '-updated' to value

    }

}
</code></pre>

<p>Fiddle <a href="https://jsfiddle.net/69zzr6xa/6/" rel="nofollow">https://jsfiddle.net/69zzr6xa/6/</a></p>
