我想将单击事件更改为onmouseover事件以打开我的div,然后如果鼠标再次离开我的div hide,就像下拉菜单一样,任何人都可以帮助我。p> html代码:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Papermashup.com | Sliding Div</title>
<script src="jquery.js" type="text/javascript"></script>
<script src="dropdown/drop.js" type="text/javascript"></script>
<link type="text/css" href="dropdown/drop.css" rel="stylesheet"/>
</head>
<body>
<a href="#" class="show_hide" onmouseover="this.#" >Show/hide</a><br />
<div class="slidingDiv" style="width:103px;height:60px;">
<img alt="" height="80" src="images/dropdown.png" width="103">
</div>
</body>
</html>
CSS代码:
.show_hide {
display:none;
}
JavaScript代码:
$(document).ready( function() {
$(".slidingDiv").hide();
$(".show_hide").show();
$('.show_hide').click( function() {
$(".slidingDiv").slideToggle();
});
});
尝试
$(".show_hide").mouseenter(function() {
$(".slidingDiv").slideToggle();
})
只需使用鼠标折线而不是单击绑定。
$('.show_hide').mouseover(function(){
$(".slidingDiv").slideToggle();
}).mouseout(function(){
$(this).slideToggle();
});