Home >Web Front-end >HTML Tutorial >How to realize that HTML text box cannot modify its content
In this article, we will share with you a basic knowledge: HTML method to realize that the text box is read-only and cannot modify the content. I hope it will be helpful to everyone.
<!--方法1: onfocus=this.blur() 当鼠标放不上就离开焦点 --> <input type="text" name="input1" value="中国" onfocus=this.blur()> <!-- 方法2:readonly 文字不会变色,也是不可编辑的--> <input type="text" name="input1" value="中国" readonly> <input type="text" name="input1" value="中国" readonly="true"> <!-- 方法3: disabled 此时文字会变成灰色,不可编辑。 --> <input type="text" name="input1" value="中国" disabled="true">
The above content is the HTML method to realize that the text box is read-only and cannot modify the content. Although it is very simple, it is indeed a practical little method. I hope it will be helpful to everyone.
Related recommendations:
jQuery implements the function of setting and removing the default value of the text box
The input text box is non-editable in html Method
Brief description of the implementation method of simultaneous input into two text boxes
The above is the detailed content of How to realize that HTML text box cannot modify its content. For more information, please follow other related articles on the PHP Chinese website!