title: select checkbox if the value is in array
body: <pre><code>var ds = $("#recDay").val().split(/ +/); 
  var weekArray = [];
  for (var i=0; i&lt;ds.length; i++){
      weekArray = ds[i];
  } // i =0 , weekArray = Sunday; i=1, weekArray = tuesday; i=2, weekArray = Wednesday
  
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td width="3%"&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="checkbox" name="weeklyDay" id="sunday" value="sunday"&gt; Sunday&lt;/td&gt;      
  &lt;td&gt;&lt;input type="checkbox" name="Day" id="monday" value="monday"&gt; Monday&lt;/td&gt;                                                                               
  &lt;td&gt;&lt;input type="checkbox" name="Day" id="tuesday" value="tuesday"&gt; Tuesday&lt;/td&gt;                                                                                
  &lt;td&gt;&lt;input type="checkbox" name="Day" id="wednesday" value="wednesday"&gt;Wednesday&lt;/td&gt;                                                                              
  &lt;/tr&gt;                                                                            
  &lt;tr&gt;                                                                                
  &lt;td width="3%"&gt;&lt;/td&gt;                                                                                
  &lt;td&gt;&lt;input type="checkbox" name="Day" id="thursday" value="thursday" &gt; Thursday&lt;/td&gt;                                                                                   
  &lt;td&gt;&lt;input type="checkbox" name="Day" id="friday" value="friday"&gt; Friday&lt;/td&gt;                                                                                 
  &lt;td&gt;&lt;input type="checkbox" name="Day" id="saturday" value="saturday"&gt; Saturday&lt;/td&gt;                                                                         
  &lt;/tr&gt;                                                                       
  &lt;/table&gt;
  </code></pre>
  
  <p>How to check only the check boxes that is in weekArray? 
  The code which I tried is</p>
  
  <pre><code>$('select[name="Day"] option').filter(function(){
           if(weekArray.indexOf((this).text(), 0) != -1);
           return $(this);
      }).prop("checked", true);
  </code></pre>
  
  <p>But this is not working. 
  Any help would be appreciated</p>