Why does my jQuery animation is not working?
Hello, I can't find any error in my simple animation. (I am counting in script and writing on page the quantity of button clicks) I want to make on button click animation which would move my 200x200px div from left to right, and then immediately, or after second click (code below), from right to left, but all I have is moving always to right or to left, depending on changes i make. I have tried using bool, but i guess that if I'm setting my var to false, it will always be false, because script loads on button click, am I right? <script> var animate = parseInt($('.countA').text(), 10); if (animate / 2 == 0) { $(".darkButton").click(function () { $(".blocky").animate({ "left": "+=500px" }, "fast"); }); } else { $('.darkButton').click(function () { $(".blocky").animate({ "left": "-=500px" }, "fast"); }); } </script> ------------------------- Any suggestions?