js解决select下拉选不中问题
2014-10-14 00:00
501 查看
当事件mouseover中出现select下拉框时,select下拉是选不中的,解决办法:
var o = e.relatedTarget || e.toElement;//判断下移动到的对象,移动到option上ie下是null,firefox等为undefined。。
if (!o) return;//为option退出不隐藏
完整代码案例为:
当鼠标移上时就不会出现选不中select的情况了。
var o = e.relatedTarget || e.toElement;//判断下移动到的对象,移动到option上ie下是null,firefox等为undefined。。
if (!o) return;//为option退出不隐藏
完整代码案例为:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style type="text/css"> *{margin:0;padding:0;list-style:none;border:0;} .pop_blue{ position:absolute; cursor:pointer; padding:10px;} .pop_blue span{ display:inline-block; width:24px; height:32px; background: url(../images/pop_blue.png) no-repeat;} .map_xf .rud1{width:210px; position:absolute;border:1px solid #ddd; display:none; background-color:#fff;padding:17px 25px;} .map_xf .rud1 li{margin:0 0 8px;} .map_xf .rud1 input,.map_xf .rud1 select{height:22px;} </style> <script type="text/javascript" src="jquery-1.9.1.min.js"></script> <script type="text/javascript"> $(function(){ $('.pop_blue').hover( function(){ $(this).find('.rud1').show(); $(this).css("z-index","9999"); }, function(e){ var o = e.relatedTarget || e.toElement;//判断下移动到的对象,移动到option上ie下是null,firefox等为undefined。。 if (!o) return;//为option退出不隐藏 $(this).find('.rud1').hide(); $(this).css("z-index","0"); } ) }) </script> </head> <body> <div style="position:relative;width:100px;height:100px"> <div class="pop_blue" style="top:0px; left:0;"> <span>鼠标移上</span><i></i> <div class="rud1 font12" style="top:10px;left:40px; display:none;padding:50px;background:blue;"> <ul> <li> <select class="w100" id="dan"> <option value="选择单元" selected="">选择单元</option> <option value="选择单元" selected="">选择单元1</option> <option value="选择单元" selected="">选择单元2</option> <option value="选择单元" selected="">选择单元3</option> <option value="选择单元" selected="">选择单元4</option> </select> </li> </ul> </div> </div> </div> </body> </html>
当鼠标移上时就不会出现选不中select的情况了。
相关文章推荐
- js解决select下拉选不中问题
- js解决select下拉问题
- 安卓系统浏览器中select下拉按钮无法弹出选择面板奇怪问题解决
- JavaScript解决select下拉框中的内容太长显示不全的问题
- 解决select右侧下拉箭头在ios上不兼容的问题
- HTML select下拉框问题解决
- iframe解决层和select下拉框显示问题
- 解决iview 的select下拉框选项错位的问题
- 一个JS图片放大镜,实现动态记录的图片放大,避免内存泄露,解决IE6下无法遮盖select控件问题
- 安卓系统浏览器中select下拉按钮无法弹出选择面板奇怪问题解决
- tinyselect.js插件下拉框的选中功能解决
- 完美解决iview 的select下拉框选项错位的问题
- asp使用js时间控件,实现下拉日历 解决UTF-8和GB2312的编码问题
- 关于JS下拉列表选择时间计算时间周期的问题解决
- 在Bootstrap的modal中使用select2出现不能显示下拉框问题解决办法
- AngularJS select首项空白问题解决方案
- Bootstrap Flat UI的select下拉框显示问题解决
- JavaScript解决select下拉框中的内容太长显示不全的问题
- Js与下拉列表处理问题解决