Skip to content


How to Enable and Disable buttons with jQuery

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>

 

Posted in JavaScript, jQuery, Web, Web Design.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.



Rss Feed Tweeter button Facebook button Technorati button Reddit button Myspace button Linkedin button Webonews button Delicious button Digg button Flickr button Stumbleupon button Newsvine button Youtube button