怎么设置下拉框 select 没有 readonly 属性

 我来答
baby单纯就是傻
2017-08-03 · TA获得超过137个赞
知道小有建树答主
回答量:381
采纳率:16%
帮助的人:347万
展开全部
html中,select下拉框中是没有readonly这个属性的,只有disabled。但是用disabled就无法将下拉框中的数据读出来,所以要想办法将select下拉框设置成只读的。
将select下拉框设置成readonly 的两种办法。
第一种:<scriptvar f=s.selectedIndex</script
<select name=s onchange=selectedIndex=f
<option1 </option
<option selected2 </option
</select第二种:<span onmousemove=this.setCapture(); onmouseout=this.releaseCapture(); onfocus=this.blur();<select<option1 </option
<option selected2 </option
</select</span
其中onmousemove=this.setCapture(); onmouseout=this.releaseCapture(); 屏蔽了鼠标事件,
onfocus=this.blur();屏蔽了键盘事件,onfocus=this.blur();表示该对象将获得焦点时就让它失去焦点,按键盘的TAB键时跳过它,使下一个控件获得焦点。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式