被禁用的 input 元素既不可用,也不可点击。可以设置 disabled 属性,直到满足某些其他的条件为止(比如选择了一个复选框等等)。然后,就需要通过 JavaScript 来删除 disabled 值,将 input 元素的值切换为可用。
以下三种写法都可以禁用 input
被禁用的 input 默认显示灰色,可以通过CSS修改样式。bjdkfp.codeplex.com;
bjkfp.codeplex.com;
bjkp.codeplex.com;
bjkpi.codeplex.com;
bjkpo.codeplex.com;
shdkfp.codeplex.com;
shdkp.codeplex.com;
shkpi.codeplex.com;
shfpo.codeplex.com;
shfpi.codeplex.com;
tjdkfp.codeplex.com;
tjfpo.codeplex.com;
tjkpi.codeplex.com;
tjkpu.codeplex.com;
tjkpy.codeplex.com;
cqkfp.codeplex.com;
cqfpo.codeplex.com;
cqkpi.codeplex.com;
cqkpu.codeplex.com;
cqkpy.codeplex.com;
hebdkfp.codeplex.com;
hebfpo.codeplex.com;
hedkp.codeplex.com;
hebmp.codeplex.com;
hebtp.codeplex.com;
jlkfp.codeplex.com;
jlkfpq.codeplex.com;
jldkp.codeplex.com;
jlkfw.codeplex.com;
jlfp.codeplex.com;
ccfp.codeplex.com;
cckfp.codeplex.com;
ccfpw.codeplex.com;
ccfpe.codeplex.com;
ccfpr.codeplex.com;
sykfp.codeplex.com;
syfpq.codeplex.com;
syfpe.codeplex.com;
sydpq.codeplex.com;
syfp.codeplex.com;
dlfpw.codeplex.com;
dlfpe.codeplex.com;
dlfpr.codeplex.com;
dlfpa.codeplex.com;
dlfps.codeplex.com;
asfpq.codeplex.com;
asfpe.codeplex.com;
asfpa.codeplex.com;
asfps.codeplex.com;
asfpd.codeplex.com;
jnfpq.codeplex.com;
jnfpw.codeplex.com;
jnfpr.codeplex.com;
jnfpt.codeplex.com;
jnfpa.codeplex.com;
jnfpd.codeplex.com;
qdfp.codeplex.com;
qdkfp.codeplex.com;
qddfp.codeplex.com;
qddkp.codeplex.com;
qdfpa.codeplex.com;
qdfpd.codeplex.com;
zbkfp.codeplex.com;
zbfpa.codeplex.com;
zbdfp.codeplex.com;
dykfp.codeplex.com;
dydkfp.codeplex.com;
dyfpk.codeplex.com;
ytkfp.codeplex.com;
ytdfp.codeplex.com;
ytfp.codeplex.com;
ytfp.codeplex.com;
wfkfp.codeplex.com;
wffpa.codeplex.com;
wffp.codeplex.com;
tykfp.codeplex.com;
tyfpq.codeplex.com;
tyfpw.codeplex.com;
tyfpe.codeplex.com;
tyfps.codeplex.com;
xafp.codeplex.com;
xafpa.codeplex.com;
xadfp.codeplex.com;
xaksp.codeplex.com;
xafpq.codeplex.com;
sjzfp.codeplex.com;
sjzkp.codeplex.com;
sjzpp.codeplex.com;
sdkfp.codeplex.com;
sjfpq.codeplex.com;
sjfpw.codeplex.com;
tsfpq.codeplex.com;
tsdfp.codeplex.com;
tsfpw.codeplex.com;
qhdfp.codeplex.com;
qhfp.codeplex.com;
qdfpq.codeplex.com;
lyfp.codeplex.com;
lyfpq.codeplex.com;
lyfpw.codeplex.com;
zzfp.codeplex.com;
zzfpq.codeplex.com;
zzfpw.codeplex.com;
zzfpe.codeplex.com;
zzfpr.codeplex.com;
whfpq.codeplex.com;
whfpw.codeplex.com;
whfpe.codeplex.com;
whfpt.codeplex.com;
whfpa.codeplex.com;
csfp.codeplex.com;
csfpq.codeplex.com;
csfpw.codeplex.com;
csfpe.codeplex.com;
csfpt.codeplex.com;
wxfp.codeplex.com;
wxkfp.codeplex.com;
wxfpq.codeplex.com;
wxdfp.codeplex.com;
wxfpw.codeplex.com;
njdfp.codeplex.com;
njfpw.codeplex.com;
njfpe.codeplex.com;
njfpa.codeplex.com;
njfps.codeplex.com;
szfp.codeplex.com;
szkfp.codeplex.com;
szfpq.codeplex.com;
szfpe.codeplex.com;
szfpw.codeplex.com;
nbfp.codeplex.com;
nbfpq.codeplex.com;
nbfpw.codeplex.com;
nbfpe.codeplex.com;
nbfpr.codeplex.com;
hzdfp.codeplex.com;
hzkfp.codeplex.com;
hzfpq.codeplex.com;
hzfpa.codeplex.com;
hzfps.codeplex.com;
fzkfp.codeplex.com;
fzfpq.codeplex.com;
fzfpe.codeplex.com;
fzfpt.codeplex.com;
fzfpy.codeplex.com;
xmfp.codeplex.com;
xmfpq.codeplex.com;
xmfpw.codeplex.com;
xmfpe.codeplex.com;
xmdfp.codeplex.com;
kmkfp.codeplex.com;
kmfp.codeplex.com;
kmfpq.codeplex.com;
kmfpr.codeplex.com;
kmfpe.codeplex.com;
cdfp.codeplex.com;
cdfpe.codeplex.com;
cdfpt.codeplex.com;
cdfpw.codeplex.com;
csfpa.codeplex.com;
hffp.codeplex.com;
hffpq.codeplex.com;
hffpw.codeplex.com;
hffpe.codeplex.com;
hffpr.codeplex.com;
gyfp.codeplex.com;
gyfpq.codeplex.com;
gykfp.codeplex.com;
gyfpr.codeplex.com;
gyfpt.codeplex.com;
xzfp.codeplex.com;
xzkfp.codeplex.com;
xzfpq.codeplex.com;
xzfpt.codeplex.com;
xzfpa.codeplex.com;
ntfp.codeplex.com;
ntdfp.codeplex.com;
ntkfp.codeplex.com;
ntfpt.codeplex.com;注:IE9及以下无法改变字体颜色。
1. 利用CSS3 :disabled 伪元素定义
//Chrome Firefox Opera Safari
input:disabled{undefined
border: 1px solid #DDD;
background-color: #F5F5F5;
color:#ACA899;
}
2. 利用属性选择符定义
//IE6 failed
input[disabled]{undefined
border: 1px solid #DDD;
background-color: #F5F5F5;
color:#ACA899;
}
3. 利用类来定义
input.disabled{undefined
border: 1px solid #DDD;
background-color: #F5F5F5;
color:#ACA899;
}
最终结果:
//Chrome Firefox Opera Safari IE9+
input:disabled{undefined
border: 1px solid #DDD;
background-color: #F5F5F5;
color:#ACA899;
}
//IE8-
input[disabled]{undefined
border: 1px solid #DDD;
background-color: #F5F5F5;
color:#ACA899;
}
//IE6 Using Javascript to add CSS class "disabled"
* html input.disabled{undefined
border: 1px solid #DDD;
background-color: #F5F5F5;
color:#ACA899;
}
注意:IE8 bug 由于IE8 不识别 :disabled 导致input[disabled],input:disabled样式失效,可以考虑单独来写,或者直接使用input[disabled]。;IE9及以下无法改变字体颜色。
来自 https://blog.csdn.net/cy12272961151353/article/details/26491593?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.no_search_link&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.no_search_link