html 文本框(text)不可用只读的多种实现方法
html 文本框(text)不可用只读的多种实现方法
发布时间:2016-12-27 来源:查字典编辑
摘要:方法一:不可用方法二:只读方法三:隐藏(但占位置)方法四:隐藏(不占位置)有时候,我们希望表单中的文本框是只读的,让用户不能修改其中的信息,...

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

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新XHTML学习
热门XHTML学习
网页设计子分类