Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/404.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript JQuery-如果您';你不是,在这个分区盘旋_Javascript_Jquery_Css_Hover_Jquery Animate - Fatal编程技术网

Javascript JQuery-如果您';你不是,在这个分区盘旋

Javascript JQuery-如果您';你不是,在这个分区盘旋,javascript,jquery,css,hover,jquery-animate,Javascript,Jquery,Css,Hover,Jquery Animate,如何说JQuery:当你不再在div>img上悬停时,做第二件事。你传递给的第二个函数是mouseleave处理程序,如下所示: cardh = 0 $('.cardgreen > img').hover(function () { if (cardh == 0) { $('.card > img').animate({ height: 150, width: 193, opacity: '1', left: 0, top: 9 }, 500);

如何说JQuery:当你不再在div>img上悬停时,做第二件事。

你传递给的第二个函数是
mouseleave
处理程序,如下所示:

cardh = 0

$('.cardgreen > img').hover(function () {
    if (cardh == 0) {
        $('.card > img').animate({ height: 150, width: 193, opacity: '1', left: 0, top: 9 }, 500);
        $('.anfahrtlink').animate({ opacity: '0' }, 500).animate({ width: 0 }, 0);
        $('.cardgreen > img').animate({ opacity: '0' }, 500).animate({ opacity: '1' }, 500);
        cardh = 1
    }
});

$('.cardgreen > img').notanymore().hover(function () {
    if (cardh == 1) {
        $('.cardgreen > img').animate({ opacity: '0' }, 300);
        $('.anfahrtlink').animate({ width: 84 }, 0).animate({ opacity: '1' }, 500);
        $('.card > img').animate({ opacity: '1' }, 300).animate({ opacity: '0', width: 0, height: 0, left: 194, top: 75}, 270);
        cardh = 0
    }
});
接受两个处理程序-对于和,或者像您一样,一个处理程序同时执行这两个操作。但是,由于您需要hover“in and out”行为,所以请使用2处理程序版本。

jQuery
.hover()
方法可以使用2个参数(请参见此处:)

handlerIn(eventObject)-鼠标指针进入元素时执行的函数。
handlerOut(eventObject)-鼠标指针离开元素时执行的函数。

@Mr.Freeman-不应该是这种情况,您有示例页面吗?
$('.cardgreen > img').hover(function() {
  $('.card > img').animate({height: 150, width: 193, opacity: '1', left: 0, top: 9},500)
  $('.anfahrtlink').animate({opacity: '0',},500).animate({width:0},0);
  $('.cardgreen > img').animate({opacity: '0'},500)
                       .animate({opacity: '1'},500);
}, function() {
    $('.cardgreen > img').animate({opacity: '0'},300);
    $('.anfahrtlink').animate({width:84},0).animate({opacity: '1',},500)
    $('.card > img').animate({opacity: '1'},300)
                    .animate({opacity: '0', width: 0, height: 0, left:194, top:75},270);
});
.hover( handlerIn(eventObject), handlerOut(eventObject) )