Я смотрел на кучу разных постов здесь относительно этого, я думаю, что я правильно слежу, но мой код не выполняется, так что, очевидно, я не так. Удивление, если кто-то здесь может заметить что-то, что я пропускаю.
У меня есть панель навигации, и когда пользователи накладываются на элемент меню, я хочу, чтобы div соскальзывал из-под него и показывал кучу контента.
Здесь разметка:
<nav class="site-navigation main-navigation" role="navigation">
<div class="menu-1-container">
<ul id="menu-1" class="menu">
<li id="menu-item-1">
<a href="#">Releases</a>
</li>
</ul>
</div>
</nav>
<div class="dropdown-contain">
<p>Content</p>
</div>
Здесь css:
.dropdown-contain {
display: none;
}
Здесь.js (все еще учась и не полностью понял):
$(document).ready(function(){
$(".menu-item-475").hover(function () {
$(".dropdown-contain").stop(true, true).slideToggle("slow");
});
});
Вот скрипка. http://jsfiddle.net/ericbrockman/mk4yu/3/
огромное спасибо!!
я немного изменил твою скрипку, посмотри здесь
вещи, чтобы заметить:
1 - you should select your jquery library on the left panel of jsfiddle.
2 - delegating event handlers by attaching them to document seem to work better for me
3 - using custom animation you have more control over the sliding
4 - set position:absolute for the sliding panel if you want it to work correctly
5 - when attaching the mouse hover to a menu item, always include the submenu as well or you will not be able to click the submenu since when you move the mouse out of the menu item the submenu goes off
если у вас есть еще вопросы, пожалуйста, дайте мне знать. -if мой ответ помог вам, пожалуйста, подумайте о его принятии :)