我有一个链接(水平导航栏项目),当用户将鼠标悬停在它上面时,另一个div
应该slideDown
就在下面。.toggle
不起作用,因为当您将鼠标悬停在链接上时,它会不断切换 div。
我尝试编写自己的使用mouseover
,mouseOut
但它太敏感并且div
在显示器之间来回翻转(块,无)。
这是我的 jQuery:
$(".topHorzNavLink").mouseover(function() {
//get which link we hovered over
var thisHorzLink = $(this).attr('linkItem');
if (thisHorzLink == "link2") {
$("#hoverContainer").slideDown('slow');
}
});
$(".topHorzNavLink").mouseout(function() {
//get which link we hovered over
var thisHorzLink = $(this).attr('linkItem');
if (thisHorzLink == "link2") {
$("#hoverContainer").slideUp('slow');
}
});
这是 HTML(我知道,呃,它在某些时候会是动态的):
<nav id="topHorzNav">
<div id="topHorzNavLinks">
<ul>
<li><p class="topHorzNavLink" linkItem="link1"><a href="#">Link 1</a></p></li>
<li><p class="topHorzNavLink" linkItem="link2"><a href="#">Link 2</a></p>
<div id="hoverContainer">
<div class="colContainer">
<div class="colContainer">
<div class="colContainer">
<div class="colContainer">
<div class="colContainer">
<!--col 1-->
<div class="col">
<p class="colHeader">Heading 1</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
</div>
<div class="colDivider"> </div>
<!--col2 -->
<div class="col">
<p class="colHeader">Heading 2</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
</div>
<div class="colDivider"> </div>
<!--col3 -->
<div class="col">
<p class="colHeader">Heading 3</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
</div>
<div class="colDivider"> </div>
<!--col4 -->
<div class="col">
<p class="colHeader">Heading 4</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
</div>
<div class="colDivider"> </div>
<!--col5 -->
<div class="col">
<p class="colHeader">Heading 5</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
<p class="colText">Lorem Ipsum Dolar</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</li>
<li><p class="topHorzNavLink"><a href="#" class="topHorzNavLink" linkItem="link3">Link 3</a></p></li>
<li><p class="topHorzNavLink"><a href="#" class="topHorzNavLink" linkItem="link4">Link 4</a></p></li>
</ul>
</div>
<div id="topHorzNavRight"> </div>
</nav>
<!--end top horz nav items-->