I’m trying to get the following code to work:
There’s this strange issue, the second .animate does not work when I use elem.data to get the values, whereas when I use mention the values specifically such as "left" : "200px" it seems to work.
I’ve checked the existence of elem.data('prevLeft') and elem.data('prevTop') by using console.log() just before the code mentioned below and these values exist and are correct.
elem.animate({"width":"200px"},3000).animate({
"left": elem.data('prevLeft'),
"top": elem.data('prevTop')
},2000);
What seems to be the problem, and is there no way I can pass values stored in a variable to the .animate() function?
A Stray function was resetting the values, and that is why it wasn’t working.
I retried all the methods mentioned and all of them worked.
Sorry for all the trouble.
EDIT, try this:
Though if svenhesse’s answer didn’t work, I’m not sure this will.