Bootstrap Disable Enable button jQuery


Bootstrap Disable Enable button jQuery : There are many ways to enable and disable the bootstrap buttons. Bootstrap provides .disable class to display the disabled state. Here in this tutorial we are going to explain how you can enable/disable the buttons using the jQuery. We will explain this functionality with example and demo.


Bootstrap Disable Enable button jQuery

You can disable and enable the button in bootstrap using the jquery as below –

Disable Example-

You can disable the bootstrap button simply as below –

Bootstrap Disable Enable button jQuery : Disable Example

<script type="text/javascript">
function disable(){
$("#myBtn").attr("disabled", true);
$('#myBtn').addClass('disabled');
}
</script>

<input type="button" class="btn btn-danger" onclick="disable()" id="myBtn" value="Disable Button" />

Try it »

If run the above example it will produce the following output like this-

Bootstrap Disable Enable button jQuery

Enable Button

You can enable the disabled button simply as below –

Bootstrap Enable button jQuery : Example

<script type="text/javascript">
function enable(){
$("#myBtn").removeAttr("disabled");
$('#myBtn').removeClass('disabled');
}
</script>
<input type="button" class="btn btn-danger disaabled" disabled id="myBtn" value="Disabled Button" />
<br>

<input type="button" class="btn btn-danger " onclick="enable()" id="myBtn" value="Enable Button" />

Try it »

If run the above example it will produce the following output like this-

Bootstrap Disable Enable button


Advertisements

Add Comment

📖 Read More