input只读效果

有两种方式可以实现input的只读效果:disabled 和 readonly。

自然两种出来的效果都是只能读取不能编辑,可是两者有很大不同。

Disabled说明该input无效,及其value不会传递给任何程序,比如asp、php等。
Readonly仅仅是无法编辑,不影响其值的传递。

Disabled使用:

<INPUT type=”text” name=”username” value=”james” disabled>


Readonly使用:

<INPUT type=”text” name=”partNumber” value=”1500″ readonly>

注:

1。IE下者表现一样,但FF下落不明readonly能聚集,但disabled不能,且有默认的背景色。

原文地址:https://www.cnblogs.com/coder-zhang/p/3654386.html