<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>input[type=checkbox]</title>
</head>
<body>
<div><input type="checkbox" value="1"></div>
<div><input type="checkbox" value="2" checked="checked"></div>
<div><input type="checkbox" value="3"></div>
<div><input type="checkbox" value="4" checked="checked"></div>
<script>
var checkedInp;
var inputs = document.getElementsByTagName('input');
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == 'checkbox' &&
inputs[i].checked) {
checkedInp = inputs[i].value;
alert(checkedInp)
}
}
</script>
</body>
</html>