手机
当前位置:查字典教程网 >网页设计 >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)不可用只读的多种实现方法】相关文章:

标签栏的几种实现方法(推荐)

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

html中设置锚点定位的几种常见方法

一些有用的meta设置方法(必看)

html文档基本结构(制作网页基础知识)

Firefox下英文字母不换行的解决方案

html text的常用事件和方法详细描述

html H标题标签的用法

表格边框/单元格之间分隔线的隐藏实现方法

html插入链接的实现方法

精品推荐
分类导航