比如以下这种情况:
<!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>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".aa").mouseover(function(){
$(".cc").show();
}).mouseleave(function(){
$(".cc").hide();
});
});
</script>
</head>
<body>
<div class="aa" style="width:800px; background:#CCC; margin:0 auto;">
<p style=" text-align:center; line-height:60px; font-size:16px;">戳我</p>
<div class="cc" style="width:720px; height:300px; margin:0 auto; background:#6CF; text-align:center; padding:20px; display:none;">
<select name="">
<option>菜单一一一一一一</option>
<option>菜单2222222222</option>
<option>333333333333333333</option>
<option>44444444444</option>
<option>555555555555</option>
</select>
</div>
</div>
</body>
</html>
鼠标经过就显示下拉菜单你可以使用hover,点击事件的话你可以自己写个onClick实现
建议你参考w3school网站学起~里面都讲的很基础详细,我就是跟着这个自学的
你需要知道此API。
检测 onmouseover 和 onmouseout 事件发生时,鼠标所进入的元素。 参考:7.fromElement
window.event.toElement
在IE下select进入option之后 ,他的值为null了..意味着已经离开了aa元素自然就触发了mouseleave
解决方案:
if (window.event.toElement == null) return;
<script>
$(document).ready(function(){
$(".aa").mouseover(function(){
$(".cc").show();
}).mouseleave(function(){
if (window.event.toElement == null) return;
$(".cc").hide();
});
});
</script>
ie移动到option会触发mouseout,应该是bug,
jquery mouseleave事件:移动到子容器select的option上也会触发
试试 firefox了