I have a form that needs JavaScript in order for a user to submit it. When my HTML is output, the disabled attribute is set to true. I want my javascript to enable the button. My JS is not enabling my button for some reason. I get no errors in the console.
The JS:
(function(){
var buttons = document.getElementsByTagName("button");
buttons[0].disabled = false;
});
The HTML:
<button type="submit" class="btn btn-primary" disabled="true">Next</button>
I have also tried DISABLED in the HTML instead of disabled="true".
Try to call the function, You are simply creating an anonymous function and not calling it at all.
(function(){
var buttons = document.getElementsByTagName("button");
buttons[0].disabled = false;
})();
//-^
Also the placement of this code is also important. Either Place the code at the end of body tag or use an onload
event.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With