我肯定犯了一些明显的错误,但它似乎就是不起作用。
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/hoverIntent.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.section').mouseover(function(){
$('#nav2').fadeOut(0).animate({"height":"30px"}, 250);
});
$('#section1').hoverIntent(navSelect('.interior','0px'));
$('#section2').hoverIntent(navSelect('.exterior','100px'));
$('#section3').hoverIntent(navSelect('.view','200px'));
function navSelect(section,selectorPosition){
return function(evt){
if ( $(section).is(':hidden')){
$('.subSection').fadeOut(250);
$(section).delay(250).fadeIn(250);
$('#selector').animate({"left":selectorPosition},250);
}}}
});
</script>
</head>.hover运行得很好,但是当我使用hoverIntent时,它什么也做不了。
发布于 2010-07-31 11:02:28
hoverIntent doesn't have a single in/out function overload,从主页:
jQuery
.hover()可以同时采用handlerIn和handlerOut,/或仅采用handlerIn。我的.hoverIntent()插件接受handlerIn和handlerOut,/或/单个配置对象。它并不是被设计成只接受像.hover()这样的handlerIn。下一个版本(r6)将更加灵活。
所以为了得到你想要的东西,你要么两次传递相同的方法,如下所示:
$('#section1').hoverIntent(navSelect('.interior','0px'), navSelect('.interior','0px'));或者,更简洁一点,您可以使用对象重载,只传递一次,但更改您的navSelect以返回该对象,如下所示:
function navSelect(section,selectorPosition){
var func = function(evt){
if ( $(section).is(':hidden')) {
$('.subSection').fadeOut(250);
$(section).delay(250).fadeIn(250);
$('#selector').animate({"left":selectorPosition},250);
}
}
return { over: func, out: func };
}https://stackoverflow.com/questions/3376585
复制相似问题