//Check Items by index
var
selIndex = [0, 2, 3];
for
(
var
i = 0; i < selIndex.length; i++) {
$(
"[id*=CheckBoxList1] input:checkbox"
).eq(selIndex[i]).prop(
'checked'
,
true
);
}
//Check Items by index
var
selIndex = [0, 2, 3];
for
(
var
i = 0; i < selIndex.length; i++) {
$(
"[id*=CheckBoxList1] input:checkbox"
).eq(selIndex[i]).prop(
'checked'
,
true
);
}
$( "[id*=CheckBoxList1] input:checkbox" ).prop( 'checked' , true ); //To check all $( "[id*=CheckBoxList1] input:checkbox" ).prop( 'checked' , false ); // To uncheck all |
$(
"[id*=CheckBoxList1] input:checked"
).each(
function
() {
alert($(
this
).next().html());
});
var
$ctrls = $(
"[id*=CheckBoxList1] input:checkbox"
);
$(
"[id*=CheckBoxList1] input:checked"
).each(
function
() {
alert($ctrls.index($(
this
)));
});
var
selectedValues = [];
$(
"[id*=CheckBoxList1] input:checked"
).each(
function
() {
selectedValues.push($(
this
).val());
});
if
(selectedValues.length>0) {
alert(
"Selected Value(s): "
+ selectedValues);
}
else
{
alert(
"No item has been selected."
);
}