У меня есть эта система навигации 2 уровня. Если я нажму на второй уровень, он не должен прятаться, а вот туда. При наведении на второй уровень отображается правильно, теперь я хочу, чтобы я нажал на суб-2 и вытащил курсор, суб-2 должен быть выбран и оставаться там.Stick навигация второго уровня onclick
$(document).ready(function() {
var $nav = $('#top_navigation > ul > li');
$nav.hover(
function() {
\t $('ul', this).stop(true, true).slideDown('fast');
$('a',this).first().css({"background-color":"#ccc", "color":"#000"});
\t },
\t function() {
$('ul', this).slideUp('fast');
$('a',this).first().css({"background-color":"#ccc", "color":"#000"});
\t }
);
});
#top_navigation {
width: 1248px;
margin: 0 auto;
position: relative;
text-transform: uppercase;
font-family: "Rounded Font", sans-serif;
font-size: 13px;
}
#top_navigation ul ul {
display: none;
}
#top_navigation ul {
padding-left: 0;
}
#top_navigation ul li {
margin: 0;
padding: 0;
float: left;
width: 100px;
height: 30px;
line-height: 30px;
font-size: 13px;
list-style: none;
}
#top_navigation ul li a {
\t display: block;
text-align: center;
text-decoration: none;
color: #000;
background-color: #FFF;
}
#top_navigation ul li.selected_menu_item a {
background-color: #ccc;
color: #FFF;
}
#top_navigation ul li a:hover {
background-color: #ccc;
color: #FFF;
}
#top_navigation li li {
height: 30px;
line-height: 30px;
border-top: #ccc 1px solid;
}
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<body bgcolor="black">
<div id="top_navigation">
\t \t <ul>
\t \t \t <li><a href="#">item1</a></li>
\t \t \t <li><a href="#">item2</a>
\t \t \t \t <ul class="submenu">
\t \t \t \t \t <li><a href="#">sub1</a></li>
\t \t \t \t \t <li><a href="#">sub2</a></li>
\t \t \t \t \t <li class="selected_menu_item"><a href="#">sub3</a></li>
\t \t \t \t </ul>
\t \t \t </li>
\t \t </ul>
\t </div>
</body>
</html>
по щелчку добавить класс к югу от элемента и при наведении курсора мыши из не slideup, если класс присутствует –