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

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">

原创文章,作者:Rosmontics,如若转载,请注明出处:https://rosmontis.com/archives/52

(1)
RosmonticsRosmontics网站管理员
上一篇 2021年7月25日 下午7:44
下一篇 2021年7月25日 下午7:56

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

评论审核已启用。您的评论可能需要一段时间后才能被显示。