проблем:JQuery проблемы с выпадающим меню
- Выпадающее
menu(#sub-button)
закрывается с помощью мыши, он должен закрыть только когда нажмите на видимой#button
- Когда, например, я стараюсь, чтобы открыть вторые выпадающий
menu(#sub-button2)
первое выпадающее меню следует закрыть немедленно, когда нажать на#button2
Html код:
<html>
<head>
<title>jquery ddm</title>
<style type="text/css">
#button {
position:fixed;
width:150px;
height:40px;
background-color:blue;
}
#sub-button {
display: none;
width:150px;
height:30px;
margin-top:41px;
background-color:cyan;
}
#button2 {
position:fixed;
width:150px;
height:40px;
background-color:orange;
}
#sub-button2 {
display: none;
width:150px;
height:30px;
margin-top:41px;
background-color:aqua;
}
</style>
</head>
<body>
<div id="button">
<div id="sub-button">6</div>
</div>
<div style="clear:both"></div>
<div id="button2" style="margin-left:152px;">
<div id="sub-button2">66</div>
</div>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/toggle.js"></script>
и код JS (toggle.js):
var myTimeout;
// show/hide sub-button menu
$("#button").click(function() {
$("#sub-button").toggle();
});
// if mouse out of button and sub-button divs - close sub-button after 860ms
$("#button").mouseout(function() {
myTimeout = setTimeout("jQuery('#sub-button').hide();",860);
});
// if timer that are about to close sub-button is launched, stop it
// by hover button or sub-button divs
$("#button").mouseover(function() {
clearTimeout(myTimeout);
});
var myTimeout2;
$("#button2").click(function() {
$("#sub-button2").toggle();
});
$("#button2").mouseout(function() {
myTimeout2 = setTimeout("jQuery('#sub-button2').hide();",860);
});
$("#button2").mouseover(function() {
clearTimeout(myTimeout2);
});
lee_gladding спасибо за предложение, это сделано не только проблемы, но я четко понимаю you'r код и может внести некоторые изменения или сделать другие кнопки. Большое спасибо! ReDEyeS, спасибо вам за ответ, я рассмотрю эту часть кода. – Sevar