-
-
Save pebriana/3e91dc7ca3bf6307d4d43993d4e84265 to your computer and use it in GitHub Desktop.
checkbox checked if the values in array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table> | |
<tr> | |
<td width="3%"></td> | |
<td> | |
<input class="weekdays" type="checkbox" name="weeklyDay" id="sunday" value="sunday">Sunday</td> | |
<td> | |
<input class="weekdays" type="checkbox" name="Day" id="monday" value="monday">Monday</td> | |
<td> | |
<input class="weekdays" type="checkbox" name="Day" id="tuesday" value="tuesday">Tuesday</td> | |
<td> | |
<input class="weekdays" type="checkbox" name="Day" id="wednesday" value="wednesday">Wednesday</td> | |
</tr> | |
<tr> | |
<td width="3%"></td> | |
<td> | |
<input class="weekdays" type="checkbox" name="Day" id="thursday" value="thursday">Thursday</td> | |
<td> | |
<input class="weekdays" type="checkbox" name="Day" id="friday" value="friday">Friday</td> | |
<td> | |
<input class="weekdays" type="checkbox" name="Day" id="saturday" value="saturday">Saturday</td> | |
</tr> | |
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var weekArray = ["saturday","monday","tuesday","friday" ]; | |
$('.weekdays').filter(function () { | |
if (weekArray.indexOf(this.id) != -1) | |
return $(this).closest('td').find(':checkbox'); | |
}).prop("checked", true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://jsfiddle.net/5xkJp/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment