Javascript 使用鼠标左键反转jquery动画
这真的让我很沮丧,因为这是一个简单的问题,我知道当有人给我一行答案的时候,我会自己面对这个问题。无论如何,我有以下关于mouseenter片段的内容Javascript 使用鼠标左键反转jquery动画,javascript,jquery,jquery-animate,mouseevent,Javascript,Jquery,Jquery Animate,Mouseevent,这真的让我很沮丧,因为这是一个简单的问题,我知道当有人给我一行答案的时候,我会自己面对这个问题。无论如何,我有以下关于mouseenter片段的内容 $("nav#primary ul li").mouseenter(function(){ $(this).find('ul:first').stop(true, true).animate({ height: ['toggle', 'swing'], opacity: 'toggle
$("nav#primary ul li").mouseenter(function(){
$(this).find('ul:first').stop(true, true).animate({
height: ['toggle', 'swing'],
opacity: 'toggle'
}, 300, 'linear');
});
我的问题是,在鼠标离开主ul li后,如何反转动画效果?如果我正确理解了您的问题,则当鼠标进入元素时,您正在设置高光和不透明度动画,当鼠标离开时,将恢复到原始状态
$("nav#primary ul li").mouseenter(function(){
//your code for mouseenter
},function(){
//your code for mouseleave
});
$( "av#primary ul li" ).hover(
function() { // on mouse enter
// save the original values
var h = $(this).css('height');
var o = $(this).css('opacity');
$(this).attr('data-Oheight',h).attr('data-Oopacity',o);
// do your animation here
}, function() { // on mouse leave
// retrive the original values
var h = $(this).attr('data-Oheight');
var o = $(this).attr('data-Oopacity');
// revert back
//do your animation to revert back
}
);
然而,话虽如此,格林斯托克还是有TweenMax工具。当涉及到此类动画需求时,它非常方便。如果您需要了解更多信息,请告诉我。我了解鼠标进入和鼠标离开的语法。我在问一个特定的问题。也就是说,鼠标离开时如何反转当前动画?