How would you target the X coordinates of a div when using an if statement?
What I’m trying to do is to get a div to animate across the screen but I only want it to move when certain x coordinates are met, hence why the if/else statements.
For example;
var firstXPos = -20px;
var secondXPos = -40px;
var thridXPos = -60px;
if (div's x pos?? == firstXPos){
$("#id").animate({"left" : secondXPos}, "slow");
} else (div's x pos?? == secondXPos?){
$("#id").animate({"left" : thridXPos}, "slow");
}
So how would write the code so that it can target the divs current x postion so that the if / else statements can be met?
I have used the following code to check an item’s visibility using x and y coordinates
so in your if statement you could use the above function to check to see if it is in that position