HTML/Xhtml
主页 > 网页 > HTML/Xhtml >

实现HTML文本框只读不能修改其中的内容的教程

2018-08-18 | 酷站 | 点击:
本篇文章给大家介绍实现HTML文本框只读不能修改其中的内容的教程

代码如下所示:


<!--方法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">

以上就是全部教程了,希望对大家有所帮助。

原文链接:
相关文章
最新更新