Reputation: 757
I've tried everything!
$('#m-button').button('disabled')
$('#m-button').attr('disabled', 'disabled')
$('#m-button').prop('disabled', 'disabled')
$('#m-button').attr('disabled', 'true')
$('#m-button').prop('disabled', 'true')
$('#m-button').attr('enabled', 'false')
<button id="m-button" class="btn" type="button" >Add Note</button>
It stays enabled though. What's the proper way to disable a <button>
?
Upvotes: 0
Views: 98
Reputation: 8321
you can try this:
$('#m-button').attr('disabled', 'disabled')
all you need is just to add disabled
attribute to your button.
Upvotes: 0
Reputation: 207901
$('#m-button').prop('disabled', true)
without quotes around true
.
Per the jQuery docs on .prop()
:
Properties generally affect the dynamic state of a DOM element without changing the serialized HTML attribute. Examples include the value property of input elements, the disabled property of inputs and buttons, or the checked property of a checkbox. The .prop() method should be used to set disabled and checked instead of the .attr() method.
Upvotes: 9