I'm pretty new to web programming (and I'm a self-taught) so I'm often confused by multiple ways of doing something.
My goal is to set the "disabled" attribute to all input hidden. Further on I'll try to remove it while showing the inputs and re-add it while hiding them. Reading around I've been able to write the below code but it works on a test page and it doesn't in my real context. (Furthermore it seems to give problems to the browser sometimes).
My questions are:
is the code correct?
is there another (simpler/better) way to do this?
var HidInp = document.querySelectorAll(".HideIt");
for (i = 0; i < HidInp.length; i++) {
var Inputs = HidInp[i].getElementsByTagName('input');
for (ii = 0; ii < Inputs.length; ii++) {
Inputs[ii].setAttribute("disabled", "");
}
}
P.S. I've also tried using the function in this answer