That’s because getElementsByName
will return you an array, more specifically an NodeList
. In assigning false
to the property disabled
of that return, you will only be creating a property called disabled
in the array, but you should be assigning this value to the items within the array, not to the array itself.
Note that in jQuery you can use a method to assign properties to all the results of your query, maybe this is what is causing confusion, but in pure Javascript you need to go through the array and assign the value to each item manually:
function botao() {
for (var titulo of document.getElementsByName("titulo")) titulo.disabled = false;
for (var descricao of document.getElementsByName("descriçao")) descricao.disabled = false;
for (var data of document.getElementsByName("data")) data.disabled = false;
for (var submit of document.getElementsByName("submit")) submit.disabled = false;
}
An interesting alternative would be to use only one
for
and capture all elements withquerySelectorAll
.– Isac