How to enable or disable an input element with jQuery
How to enable/disable an input element with jQuery – Edit content (add a revision)
If you want to disable an element with pure HTML then you would add a property called disabled : [code,html] ------ <input type="submit" name="submit" id="submit_btn" disabled="disabled" /> ------ but if you want to do this dynamically you can use Javascript. An example where this is needed : you perform an AJAX request and you don't want the user to be able to do several clicks on the button that triggers the request. A simple implementation would be .. disable the button before triggering the AJAX request and enable the button after your call successfully ended. Here is the jQuery code for enabling / disabling the button from the code above : [code,javascript] ------ // Disable button $("#submit_btn").attr("disabled", true); // Enable button $("#submit_btn").removeAttr("disabled"); ------
Save as new Revision
Syntax docs