.animate with a += variable value?
Good day!
I'm getting my teeth into jQuery and I'm trying to add a variable Number to an objects position, at the moment I can only add a Number or use an = variable value. This is my working code:
- var xMove = 200;
- var speed = 2000;
- $("#clickhere").click(function() {
- $("#animate1").animate({ left: xMove }, speed);
- });
- });
But I want something that works like this:
- var xMove = 200;
- var speed = 2000;
- $("#clickhere").click(function() {
- $("#animate1").animate({ left: +=xMove }, speed);
- });
- });
Like I said using a fixed Number instead of a variable works too so it seems like it should be straighforward.
Is my syntax just wrong or is it not that simple?
Big thanks, Jack