-4

For example, I could have a HTML form like this:

<form>
  <fieldset disabled>
    <!-- inputs here -->
  </fieldset>
</form>

How can I use JavaScript to add or remove the disabled attribute?

unknownA
  • 891
  • 1
  • 11
  • 20
  • Seriously, Whoever down-voted, Explain what problem you have with this question? And don't just say that doing what i want is impossible, Because for a fact I did not know that so maybe you could explain that in an answer? – unknownA Sep 14 '14 at 13:53
  • @DavidThomas Yes, a typo. I will fix that now. – unknownA Sep 14 '14 at 13:56
  • 3
    There's a distinct lack of research here. https://www.google.co.uk/search?q=remove%20attribute – Quentin Sep 14 '14 at 13:57
  • @MarkieJonesWTF The downvote tooltip reads: *"**this question does not show any research effort**; it is unclear or not useful"* – T J Sep 14 '14 at 14:46

1 Answers1

2

Give this a go:

document.getElementsByTagName("fieldset")[0].removeAttribute("disabled");
Simon Adcock
  • 3,484
  • 3
  • 24
  • 41
James Richford
  • 134
  • 2
  • 7
  • Thanks for your help. I'll try it now and give you my results when I'm done. However, If i want to add the attribute again, Do i just use addAttribute? – unknownA Sep 14 '14 at 13:56
  • setAttribute should work for you http://www.w3schools.com/jsref/met_element_setattribute.asp :) – James Richford Sep 14 '14 at 13:58
  • 1
    @JamesRichford My humble request: Please sharing links to w3schools. They contains lots of outdated and misleading info.. – T J Sep 14 '14 at 14:49