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() {
$("#
").attr("disabled", "disabled");btnClear
}); // click()
$("#btnEnable
").click(function() {
$("#
").removeAttr("disabled");btnClear
}); // click()
}); // ready()
// ]]></script>
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.