I have slightly modified the code here https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_getelementsbyname_loop
From:
<!DOCTYPE html>
<html>
<body>
Cats: <input name="animal" type="checkbox" value="Cats">
Dogs: <input name="animal" type="checkbox" value="Dogs">
<p>Click the button to check all checkboxes that have a name attribute with the value "animal".</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var x = document.getElementsByName("animal");
var i;
for (i = 0; i < x.length; i++) {
if (x[i].type == "checkbox") {
x[i].checked = true;
}
}
}
</script>
</body>
</html>
To: i.e. I want to change the value of value's attribute.
for (i = 0; i < x.length; i++) {
if (x[i].type == "checkbox") {
x[i].setAttribute("value", "camels");
}
}
It didn't change nothing, but What wrong am I doing?
Edit: Requirement is to change the property in DOM not HTML.

x[i].value = "camels";. BTW,setAttributeshould work too, did you change anything else by any chance?setAttributedidnt.