如何通过“onmouseover”删除选择列表?
如何使用 onmouseover 下拉选择列表而不是单击它。 无法在 JavaScript 中单击选择列表来模拟它。 例如: onmouseover="(this.click())"
另外,在 javascript 中设置“选择列表的大小”=“其长度”并不能准确模拟单击事件,因为相邻布局发生了变化。 我尝试使用 z-index 和位置属性,但没有帮助。
How can I drop down a select list with onmouseover instead of clicking it.
Select list cannot be clicked in javascript to emulate that.
eg: onmouseover="(this.click())"
Also setting the 'size of select list' = 'its length' in javascript does not accurately emulate the click event because the adjacent layout changes.
I tried using z-index and position attribute but doesn't help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
的巧妙技巧
这是来自旧的 devshed 帖子选择框 展开 onMouseOver - Dev Shed
这是一个实际示例:
http://jsfiddle.net/87nyG/1< /a>
就我个人而言,我更喜欢第 3 方或自定义解决方案,而不是破解
Here's a clever hack from an oldish devshed post
Select box expand onMouseOver - Dev Shed
here's an example in action:
http://jsfiddle.net/87nyG/1
Personally I'd prefer a 3rd party or custom solution as opposed to hacking the
<select>
element它可能会有所帮助:https://developer.mozilla.org/en/DOM/event。 initMouseEvent
编辑。不,事实并非如此:(
It might help: https://developer.mozilla.org/en/DOM/event.initMouseEvent
edit. Nah, it doesn't :(
使用本机 HTML Select 无法完成您所要求的操作。您必须寻找第三方选项。
看看这里的可能性:http://jquery.sanchezsalvador.com/page/jquerycombobox。 ASPX
It isn't possible to do what you're asking using a native HTML Select. You'll have to search out third party options.
Take a look at here for a possibility: http://jquery.sanchezsalvador.com/page/jquerycombobox.aspx
刚刚遇到这个问题。我知道这个问题已经得到解答,但如果有人来这里寻找更优雅的解决方案,您可以使用 jquery 来实现:
这将防止“黑客”HTML 中的
select
标记。Just ran into this problem. I know it was answered already, but if anyone comes here looking for a more elegant solution, you can do this with jquery:
This will prevent 'hacking' the
select
tag in the HTML.