首页前端开发HTMLhtml 文本框(text)不可用只读的多种实现方法

html 文本框(text)不可用只读的多种实现方法

时间2024-01-27 08:18:03发布访客分类HTML浏览409
导读:收集整理的这篇文章主要介绍了html 文本框(text 不可用只读的多种实现方法,觉得挺不错的,现在分享给大家,也给大家做个参考。 方法一: <input id= "File1" tyPE= "text" disabled/...
收集整理的这篇文章主要介绍了html 文本框(text)不可用只读的多种实现方法,觉得挺不错的,现在分享给大家,也给大家做个参考。 方法一: input id= "File1" tyPE= "text" disabled/> 不可用
方法二: input id= "File1" type= "text" readonly/> 只读
方法三: input id= "File1" type= "text" style="display:none"/> 隐藏(但占位置)
方法四: input id= "File1" type= "text" style="visibilITy:hidden"/> 隐藏(不占位置)

有时候,我们希望表单中的文本框是只读的,让用户不能修改其中的信息,如使input type="text" name="input1" value="中国"> 的内容,"中国"两个字不可以修改。实现的方式归纳一下,有如下几种。

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

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!

html文本框

若转载请注明出处: html 文本框(text)不可用只读的多种实现方法
本文地址: https://pptw.com/jishu/587950.html
DIV背景半透明文字不半透明的样式 Html注释 Html中标记文字注释的符号

游客 回复需填写必要信息