AngularJS进阶 三 HTML 让表单 文本框只读,不可编辑的方法

HTML:让表单、文本框只读,不可编辑的方法

有时候,我们希望表单中的文本框是只读的,让用户不能修改其中的信息,如使<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>

很简单,但有时候很有用!

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!希望你也加入到我们人工智能的队伍中来!http://www.captainbed.net

猜你喜欢

转载自www.cnblogs.com/bollala/p/10087936.html
今日推荐