How jquery changes elements to read-only
Editor to share with you how jquery changes the elements to read-only. I hope you will get something after reading this article. Let's discuss it together.
Jquery changes the element to read-only method: 1, use the "$(specified element)" statement to get the specified element object; 2, use the attr () method and readonly attribute to change the element into a read-only state, and the syntax is "element object .attr (" readonly "," readonly ")".
The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.
In css, you can use the attr () method to change the element to a read-only state, and the attr () method to set or return the property value of the selected element.
The syntax is:
$(selector) .attr (attribute,value)
Just set the readonly property of the element to readonly. The readOnly property sets or returns whether the text field is read-only.
Let's take a look at how to make a text box element read-only through an example. Examples are as follows:
Function demo () {$("input [name=demo]") .attr ("readonly", "readonly");}