title: jQuery - IF IN String or Array Condition
body: <p>With Jquery, I'm looping through the attribute named <code>tags</code>, in each <code>&lt;option&gt;</code> of the <code>&lt;select&gt;</code> dropdown below.</p>
  
  <p>You'll see I would LOVE to have 2 of the options preselected, if the number 6 exists in the <code>tags</code> attribute.  </p>
  
  <pre><code>&lt;select name="someFun" id="someFun"  multiple="multiple"&gt;
    &lt;option value="1" tags="4,6,7"&gt;something&lt;/option&gt;
    &lt;option value="44" tags="2"&gt;something&lt;/option&gt;
    &lt;option value="61" tags="1,3,6"&gt;something&lt;/option&gt;
    &lt;option value="44" tags="2"&gt;something&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;script language="javascript" type="text/javascript"&gt;
  $(document).ready(function(){
  
    var preselectedtag = '6'; // auto select any with 6
  
    $("#someFun &gt; option").each(function() {
       var tag = $(this).attr("tags");
  
       /* change attr of this option to "selected" if 6 exists in var tag */
  
    });
  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>I could use some help here. Is there a best way to do this?<br>
  In PHP I normally use an in_array() function, but javascript seems way more picky.</p>