您的位置:首页 > Web前端 > HTML

html select模拟readonly

2015-11-10 19:04 561 查看
select不支持readonly,只能用其他办法去模拟readonly了,效果就是点击select选择元素,然后自动变回默认的。

<select id="test" onfocus="this.defaultIndex=this.selectedIndex;" onchange="this.selectedIndex=this.defaultIndex;">
<option value="1">test1</option>
<option value="2">test2</option>
<option value="3">test3</option>
<option value="4"<span style="font-family: Arial;"> selected="selected"</span><span style="font-family: Arial;">>test4</option></span>
<option value="5">test5</option>
</select>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: