社区
JavaScript
帖子详情
请问如何用JS实现打开select列表
why_DK37
2011-03-04 11:38:30
如题,
用js实现鼠标点击select右边箭头,打开select所以选项的功能。
谢谢!
...全文
580
8
打赏
收藏
请问如何用JS实现打开select列表
如题, 用js实现鼠标点击select右边箭头,打开select所以选项的功能。 谢谢!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
8 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
碧海情天-赵亮
2011-03-05
打赏
举报
回复
[Quote=引用 6 楼 why_dk37 的回复:]
引用 4 楼 theforever 的回复:
<select size=2 onscroll="theforever_csdn(this);">
<option>theforever111</option>
<option>theforever222</option>
没错 ,这样就可以实现全都用键盘操作了。要的就是这个效果。[/Quote]
我也才明白你的意思,更合适的代码是这样:
<select id="s">
<option>theforever111</option>
<option>theforever222</option>
<option>theforever3333</option>
</select>
<input type="button" onclick="theforever_csdn()" value="显示所有选项" />
<script type="text/javascript">
function theforever_csdn(){
document.getElementById("s").size=document.getElementById("s").options.length;
}
</script>
KeepMoving
2011-03-04
打赏
举报
回复
我也觉得没意义!
碧海情天-赵亮
2011-03-04
打赏
举报
回复
你得点向下的箭头.向上的箭头,从意义上也说不过去.
<select size=2 onscroll="theforever_csdn(this);">
<option>theforever111</option>
<option>theforever222</option>
<option>theforever3333</option>
<option>theforever4444</option>
<option>theforever5</option>
</select>
<script type="text/javascript">
function theforever_csdn(o){
o.size=o.options.length;
}
</script>
why_DK37
2011-03-04
打赏
举报
回复
[Quote=引用 1 楼 weiyanli20080 的回复:]
什么意思不太明白!本来点击箭头,不就能显示所有选项吗?
[/Quote]
是要加一个js快捷键,所以需要用js打开select的列表。
碧海情天-赵亮
2011-03-04
打赏
举报
回复
默认不就这样吗.
你设置了高度限制?
KeepMoving
2011-03-04
打赏
举报
回复
什么意思不太明白!本来点击箭头,不就能显示所有选项吗?
flyerwing
2011-03-04
打赏
举报
回复
focus()?
不太明白.
why_DK37
2011-03-04
打赏
举报
回复
[Quote=引用 4 楼 theforever 的回复:]
你得点向下的箭头.向上的箭头,从意义上也说不过去.
<select size=2 onscroll="theforever_csdn(this);">
<option>theforever111</option>
<option>theforever222</option>
<option>theforever3333</option>
<option>theforever4444<……
[/Quote]
没错 ,这样就可以实现全都用键盘操作了。要的就是这个效果。
JavaScript
87,993
社区成员
224,694
社区内容
发帖
与我相关
我的任务
JavaScript
Web 开发 JavaScript
复制链接
扫一扫
分享
社区描述
Web 开发 JavaScript
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章