Loading...
You are here:  Home  >  JavaScript  >  Current Article

How to Enable and Disable buttons with jQuery

By   /   July 29, 2011  /   No Comments

We can use the the simplicity of jQuery to easily enable and/or disable buttons with JavaScript using jQuery. The enable/disable methods can be called on any event like onfocus, onload, onClick etc.

The below example explains the disable and enable f buttons with jQuery.

<div><button id="btnDisable">Disable</button>


<button id="btnEnable">Enable</button></div>


<button id="btnClear">Test me button</button>


<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script><script type="text/javascript">// <![CDATA[
jQuery(document).ready(function($) {
$("#btnDisable").click(function() {
$("#btnClear").attr("disabled", "disabled");
}); // click()
$("#btnEnable").click(function() {
$("#btnClear").removeAttr("disabled");
}); // click()
}); // ready()

// ]]></script>

 

    Print       Email

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

You might also like...

Image bre-pettis.jpg

Backstage At Disrupt NYC 2012 With MakerBot’s Bre Pettis

Read More →