- 怎样使input中的内容为只读,也就是说不让用户更改里面的内容。
- <input type="text" name="input1" value="中国" />
- <input type="text" name="input1" value="中国" readonly />
- <input type="text" name="input1" value="中国" disabled />
- 最好不要用disabled,不然就无法取出里面的值了.
- <input type="text" name="input1" value="中国" readonly="true" />
- <input type="text" name="input1" value="中国" readonly />
- 区别:
- 1.disabled -- 完全不可编辑,并且是不能复制的。
- 2.readonly -- 不可编辑,但是是可以复制。
- 3.Readonly只针对input(text / password)和textarea有效,而disabled对于所有的表单元素都有效,包括select, radio, checkbox, button等。
- 4.表单元素在使用了disabled后,当我们将表单以POST或GET的方式提交的话,这个元素的值不会被传递出去,而readonly会将该值传递出去
- 同点:
- 使input不可编辑。
- //该片段来自于http://www.codesnippet.cn/detail/22112012585.html
来源: http://www.codesnippet.cn/detail/22112012585.html