0

Having a small issue with my function here can't seem to work out why it's not recognising my code here. Anyone know what I'm doing wrong?

Thanks in advance.

function disabled() {
  document.getElementById('addBtn').disabled = true;
}
<div class="col-lg-12">
  <button type="submit" id="addBtn" class="btn btn-default" onclick="disabled()">
    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add Fine
  </button>
</div>
  • See the duplicate. You're hitting the `disabled` property of the `button` element before the search through scope finds the global `disabled` function. Use `addEventListener` instead. – Quentin Oct 07 '20 at 14:58
  • a) don't use inline event handlers. b) if you must, don't use names for the functions that are already used in other contexts. – connexo Oct 07 '20 at 14:59

1 Answers1

0

There is a problem on the function name. Please change the name and try.

function disabled() {
  document.getElementById('addBtn').disabled = true;
}
<div class="col-lg-12">
  <button type="submit" id="addBtn" class="btn btn-default" onclick="submitClick()">
    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add Fine
  </button>
</div>
Derek Wang
  • 10,098
  • 4
  • 18
  • 39