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

input type是什么意思及常用限制input的方法

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

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

html文档中的 ol 元素的序号数字极限探讨

将html文本中所有的标签替换掉的方法

Button的四种Click响应方法汇总

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

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

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

HTML中的文本框textarea标签

精品推荐
分类导航