Javascript 如果值在数组中,请选中复选框
但这是行不通的。Javascript 如果值在数组中,请选中复选框,javascript,jquery,checkbox,Javascript,Jquery,Checkbox,但这是行不通的。 如果您正在使用选择复选框的选择器复选框,将不胜感激 $('select[name="Day"] option').filter(function(){ if(weekArray.indexOf((this).text(), 0) != -1); return $(this); }).prop("checked", true); if(in_array(document.getElementById("CheckBoxId"), $y
如果您正在使用
选择复选框的选择器复选框,将不胜感激
$('select[name="Day"] option').filter(function(){
if(weekArray.indexOf((this).text(), 0) != -1);
return $(this);
}).prop("checked", true);
if(in_array(document.getElementById("CheckBoxId"), $yourArray)) { CheckBox.Checked }
for(var i=0;i您可以这样做
for (var i=0; i<ds.length; i++){
weekArray = ds[i];
}
$("form input:checkbox").each(function(){
if(jQuery.inArray($(this).attr('id'), weekArray )!=-1)
$(this).prop('checked', true);
});
我的复选框在div中。我应该对其进行任何更改吗?是的,您可以…因为$(输入:复选框)
查找文档中的所有复选框..准确地说,您可以将divs id添加到其中..$(#divID输入:复选框)
$('#divID input:checkbox').each(function(){
if($.inArray($(this).val(), weekArray) != -1){
$(this).prop("checked", true);
}
});
for (var i=0; i<ds.length; i++){
weekArray = ds[i];
}
$("form input:checkbox").each(function(){
if(jQuery.inArray($(this).attr('id'), weekArray )!=-1)
$(this).prop('checked', true);
});
var weekArray = ["saturday","monday","tuesday","friday" ];
$('.weekdays').filter(function () {
if (weekArray.indexOf(this.id) != -1)
return $(this).closest('td').find(':checkbox');
}).prop("checked", true);