手机
当前位置:查字典教程网 >网页设计 >XHTML >html 文本框(text)不可用只读的多种实现方法
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>

【html 文本框(text)不可用只读的多种实现方法】相关文章:

HTML表格边框的控制实现代码

创建新元素的三种方法小结

html插入链接的实现方法

html-css设置标签样式不起作用的2点原因

HTML中让表单input等文本框为只读不可编辑的方法

在html中添加script脚本的2种方法和注意事项

iframe如何刷新的三种实现方案

html H标题标签的用法

html中div不自动换行、强制不换行的具体实现

HTML中的文本框textarea标签

精品推荐
分类导航