0

I have multiple input tags like below:

<input type="checkbox" class="check" disabled id="identifier">

and:

<input type="checkbox" class="check" disabled>

I'd like to disable disabled attribute.

If i do it like this:

document.getElementById("identifier").removeAttribute('disabled');

Everything seems to work fine. However when i try to disable this attribute by getting elements by class name, the elements won't disable. I tried following examples:

document.getElementsByClassName("check").removeAttribute('disabled');

and:

document.querySelectorAll(".check").removeAttribute('disabled');

Both examples won't work. Could you please spot what am I doing wrong? I would really appreciate some help ;). Thanks in advance.

cikcirikcik
  • 161
  • 1
  • 1
  • 12

1 Answers1

0

getElementsByClassName and querySelectorAll returns array...

document.getElementsByClassName("check")[0].removeAttribute('disabled')

This would work for the first element... If you want all elements you need to loop through them.

digitalniweb
  • 838
  • 1
  • 7
  • 15