Home >Web Front-end >JS Tutorial >The text box can only select data into the text box and prohibit manual input_jquery

The text box can only select data into the text box and prohibit manual input_jquery

WBOY
WBOYOriginal
2016-05-16 17:12:541325browse

I encountered a problem today in Suzhou. The text box can only be filled with selected data. Manual entry is not possible. Checked the information. The final solution is as follows.

Page code:

Copy code The code is as follows:



Script (giving text Used when assigning values ​​to the box):
Copy code The code is as follows:

$("#id ").removeAttr("readonly"); //Remove the readonly attribute
$("#id").val("Your value");
$("#id").attr("readonly ","readonly"); //Add the readonly attribute

This achieves this small function
[/code]
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn