Sometimes we need to enable/disable a button based on some condition. We can do this easily by using "disable" attribute of a button.
Example:
<button type="button" id="voteButton">vote</button>
To disable a button write the below line:
$("#voteButton").attr('disabled', 'disabled');
or
$("#voteButton").attr("disabled",false);
To enable again after disabling the button:
$('#voteButton').removeAttr('disabled');
or
$('#voteButton').attr("disabled",true);
Hope this will help you :)
0 Comment(s)