I want to get values into an array (checkslist) from checked checkboxes. I tried this code but it does not seems to work. In the for I can get "checkslist"s items which is push but after for it can't. How can I get all the checked CheckBoxes's values into an array or list?
$(function() {
$("#btnEkle").click(
function() {
var checkbox, checkslist, menuId, text, vModel;
checkslist = [];
checkbox = document.getElementsByClassName("checks");
for (var i = 0; checkbox.length; ++i) {
if (checkbox[i].checked) {
menuId = checkbox[i].value;
checkslist.push(menuId);
}
}
alert(checkslist[0].value)
})
})