Let’s say I have these two functions:
$(".a").animate(
{"left":"100%"},
{duration:10000, complete:function(){
//Something is triggered!! e.g
alert("a");
//Please note: In actual case it is never as simple as alert("a").
}}
);
$(".b").mouseover(function(){
$(".a").stop().animate({"top":"100px"},{duration:5000});
});
-
According to these,
.awould stop as long as.bis
mouseover-ed andanimate({"top":"100px"},{duration:5000})would
be triggered. -
But I want it to
alert("a")once when.bismouseover-ed
and then triggeranimate({"top":"100px"},{duration:5000}).
However, I can’t set the second function this way:
$(".b").mouseover(function(){
//something happens! e.g
alert("a");
$(".a").stop().animate({"top":"100px"},{duration:5000});
});
- It would
alert("a")twice if.bismouseover-ed after.adone
animate.
I’ve tried stop()‘s jumpToEnd parameter and it is not ideal
Whenever .b is mouseover-ed , .a‘s animte would complete instantly and .a would be shifted to left:100%. I want it to stop at where it is and yet alert("a") before second animate being triggered
I would be extremely grateful if someone can provide a fast and easy solution for this!
1 Answer