input框如何设置框禁止输入

1.readonly 属性

<input type="text" value="666" readonly="readonly">

语法

<input readonly="value">

属性值

描述
readonly 把输入字段设置为只读。

备注

readonly 属性规定输入字段为只读。只读字段是不能修改的。
不过,用户仍然可以使用 tab 键切换到该字段,还可以选中或拷贝其文本。

2.disabled 属性

<input type="text" value="666" disabled="disabled">

语法

<input disabled="value">

属性值

描述
disabled 禁用一个 input 元素。

备注

disabled 属性规定应该禁用 input 元素。
被禁用的 input 元素既不可用,也不可点击。
disabled 属性无法与 < input type=“hidden”/> 一起使用。

猜你喜欢

转载自blog.csdn.net/qq_45844443/article/details/116715717