I\'ve seen it\'s jquery equivalent:
$(\'input[value=\"something\"]\');
But how do you select it using pure javascript (no jQuery).
Something like this works:
function getCheckboxByValue(v) {
var inputs = document.getElementsByTagName('input');
for (var i = 0; i < inputs.length; i++) {
if(inputs[i].type == "checkbox" && inputs[i].value == v) {
return inputs[i];
}
}
return false;
}
(function testCheckbox() {
getCheckboxByValue("1").checked = true;
})();
Using jQuery would be much better, though.