var ds = $("#recDay").val().split(/ +/);
var weekArray = [];
for (var i=0; i<ds.length; i++){
weekArray = ds[i];
} // i =0 , weekArray = Sunday; i=1, weekArray = tuesday; i=2, weekArray = Wednesday
<table>
<tr>
<td width="3%"></td>
<td><input type="checkbox" name="weeklyDay" id="sunday" value="sunday"> Sunday</td>
<td><input type="checkbox" name="Day" id="monday" value="monday"> Monday</td>
<td><input type="checkbox" name="Day" id="tuesday" value="tuesday"> Tuesday</td>
<td><input type="checkbox" name="Day" id="wednesday" value="wednesday">Wednesday</td>
</tr>
<tr>
<td width="3%"></td>
<td><input type="checkbox" name="Day" id="thursday" value="thursday" > Thursday</td>
<td><input type="checkbox" name="Day" id="friday" value="friday"> Friday</td>
<td><input type="checkbox" name="Day" id="saturday" value="saturday"> Saturday</td>
</tr>
</table>
如何仅选中 weekArray 中的复选框?我试过的代码是
$('select[name="Day"] option').filter(function(){
if(weekArray.indexOf((this).text(), 0) != -1);
return $(this);
}).prop("checked", true);
但这不起作用。任何帮助,将不胜感激