一:input不可輸入
A:disabled 屬性規(guī)定應(yīng)該禁用 input 元素,被禁用的 input 元素,不可編輯,不可復(fù)制,不可選擇,不能接收焦點(diǎn),后臺(tái)也不會(huì)接收到傳值。設(shè)置后文字的顏色會(huì)變成灰色。disabled 屬性無(wú)法與 <input type="hidden"> 一起使用。
示例:<input type="text" disabled="disabled" />
有時(shí)可以用:<input type="text" disabled />
B:readonly 屬性規(guī)定輸入字段為只讀可復(fù)制,但是,用戶可以使用Tab鍵切換到該字段,可選擇,可以接收焦點(diǎn),還可以選中或拷貝其文本。后臺(tái)會(huì)接收到傳值. readonly 屬性可以防止用戶對(duì)值進(jìn)行修改。
readonly 屬性可與 <input type="text"> 或 <input type="password"> 配合使用。
示例:<input type="text" readonly="readonly">
有時(shí)可以用:<input type="text" readonly/>
C:readonly unselectable="on" 該屬性跟disable類似,input 元素,不可編輯,不可復(fù)制,不可選擇,不能接收焦點(diǎn),設(shè)置后文字的顏色也會(huì)變成灰色,但是后臺(tái)可以接收到傳值。 示例:<input type="text" readonly unselectable="on" >
PS:a.input輸入框 ios端 readyonly 點(diǎn)擊出現(xiàn)光標(biāo)
input輸入框加了readonly屬性就可以達(dá)到只讀的效果,但是在ios端,點(diǎn)擊該輸入框還是會(huì)出現(xiàn)光標(biāo)解決辦法,給輸入框加上 unselectable="on" onfocus="this.blur()"
<input type="text" value="(1-5000元)" readonly unselectable="on" onfocus="this.blur()"/>
b.移動(dòng)端的input 設(shè)置只讀readonly性在蘋(píng)果手機(jī)上面不起作用會(huì)出現(xiàn)光標(biāo) 解決方案 加上樣式:-webkit-user-select :none 即可
二:input禁止軟件盤(pán)彈出
A:<input type="text" readonly="readonly" /> // <input type="text" readonly />
B:<input type="text" onfocus="this.blur()" />
C:<input type="text" id="box" />
JS:$("#box").focus(function(){
document.activeElement.blur();
});