Home >Web Front-end >Front-end Q&A >How to remove readonly attribute in jquery
In jquery, you can use the removeAttr() method to remove the readonly attribute of an element. This method can remove the specified attribute from the selected element. The syntax is "$(selector).removeAttr("readonly") ".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
The readonly attribute specifies that the input field is read-only. Read-only fields cannot be modified. However, users can still tab to the field and select or copy its text.
The readonly attribute prevents users from modifying the value until certain conditions are met (such as a checkbox being selected).
jquery removes readonly (read-only) effect
In jquery, you can use the removeAttr() method to remove the readonly attribute of an element
removeAttr() method is used to remove attributes from selected elements.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script src="js/jquery-1.10.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("button").click(function() { $("textarea").removeAttr("readonly"); }); }); </script> </head> <body> <textarea readonly="readonly">测试文本</textarea><br><br> <button>移除readonly(只读)效果</button> </body> </html>
[Recommended learning: jQuery video tutorial, web front-end development video]
The above is the detailed content of How to remove readonly attribute in jquery. For more information, please follow other related articles on the PHP Chinese website!