onmouseout如何关闭组合框? [英] how to close combobox when onmouseout?

查看:93
本文介绍了onmouseout如何关闭组合框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在onmouseout时关闭组合框?

 < select onmouseout => 
< option value =volvo>沃尔沃< / option>
< option value =saab> Saab< / option>
< option value =mercedes> Mercedes< / option>
< option value =audi> Audi< / option>
< / select>


解决方案

您无法做到这一点(可靠)。出现的弹出窗口不可用于以编程方式操作(即打开或关闭),并且其行为由浏览器(或操作系统)定义。



为了进一步扩展,IE和Firefox都可以通过模糊select元素来关闭弹出窗口:

  selectEl.blur(); 

虽然鼠标移动到鼠标时触发 mouseout 事件弹出窗口中的选项,所以它需要一点骇人听闻的魔力。在Chrome中,它会模糊选择元素,但该框将保持打开状态。



通常最好是保留UI组件的行为,以便用户获得他们期望的体验通过与您的网站互动。

How to close combobox when onmouseout?

<select onmouseout="">
 <option value="volvo">Volvo</option>
 <option value="saab">Saab</option>
 <option value="mercedes">Mercedes</option>
 <option value="audi">Audi</option>
</select>

解决方案

You can't do this (reliably). The popup that appears is not available to manipulate, ie open or close, programmatically and its behaviour is defined by the browser (or operating system).

To expand on this further, both IE and Firefox can close the popup by blurring the select element:

selectEl.blur();

Although, the mouseout event fires even when you move the mouse to the options in the popup, so it would require a bit of hackery magic. In Chrome it will blur the select element but the box will remain open.

It's generally best to leave the behaviour of UI components alone, so that users get the experience they expect through interaction with your website.

这篇关于onmouseout如何关闭组合框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆