Javascript JQuery-如果您';你不是,在这个分区盘旋
如何说JQuery:当你不再在div>img上悬停时,做第二件事。你传递给的第二个函数是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);
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) )