- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to disable/enable an input box with jQuery?
We can easily disable input box(textbox,textarea) using disable attribute to “disabled”.
$(‘elementname’).attr(‘disabled’,’disabled’);
To enable disabled element we need to remove “disabled” attribute from this element.
$(‘elementname’).removeAttr(‘disabled’);
Example
<html > <head> <title>ed</title> <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $('#btn1').click(function () { $('input').attr('disabled', 'disabled'); }); $('#btn2').click(function () { $('input').removeAttr('disabled'); }); }); </script> </head> <body> <div> <input type="text" id="tt1" /><br /> <button type="button" id="btn1">Disable</button> <button type="button" id="btn2">Enable</button> </div> </body> </html>
- Related Articles
- How to disable/ enable checkbox with jQuery?
- How to enable and disable submit button using jQuery?
- How to globally disable an animation using jQuery?
- How to disable spell check from input box and text area in HTML forms?
- How to disable autocomplete of an HTML input field?
- How to Disable / Enable a Button in TKinter?
- How to enable/disable log levels in Android?
- How to enable/disable data connection in iOS programmatically?
- How to enable/disable the GPS programmatically in Android?
- How to Enable and Disable Root Login in Ubuntu?
- How to create a text input box with Pygame?
- How to enable or disable the GPS programmatically on Kotlin?
- How to disable right click using jQuery?
- How to limit an HTML input box so that it only accepts numeric input?
- How to input letters in capital letters in an edit box in Selenium with python?

Advertisements