4

我有一个要求——当用户将鼠标悬停在链接上时,我必须折叠一个选择框。

我的代码似乎适用于 FF 和 IE,但不适用于 Safari 和 Chrome。这是它的简化版本。

请告知我错过了什么?

编辑:感谢 Rob 指出这一点。当我说“我必须失去焦点”时,我的意思是,“我必须折叠选择框并将焦点移出/模糊”。

编辑:我想我的问题和总结不正确/具有误导性。我试图改写它,以显示我的要求/问题。无论如何,就是我现在所拥有的。这是一个 hack,但它现在似乎也可以在 Chrome 上运行,但是 Safari 仍然很难获得。有什么建议吗?

4

1 回答 1

1

I'm guessing this is way past your need for this, and it's not a "good" solution, but in case anyone happens upon this. I was able to get it to work in Chrome with your existing code only by hiding the select on hover of the link, then showing it again when the mouse leaves (I didn't try Safari).

http://jsfiddle.net/52enE/

There's another solution to create a dummy select, but it was reported as not working in the latest chrome at the time:

Close a SELECT dropdown list programatically with Javascript/jQuery

Since the browser controls the select and how form elements are viewed there's probably no good way around this...the "best" (still not good) solution would probably be to use a custom input that acts like a select but can be fully controlled with a hide() call...or find a way to change the requirements :)

于 2012-09-11T21:15:02.140 回答