I have this script:
var speed = 10;
if(left && !right){ // Move siteA
$(siteA).animate({'left':'+=10'}, 0);
}
if(right && !left){
$(siteA).animate({'left':'-=10'}, 0);
}
if(up && !down){
$(siteA).animate({'top':'+=10'}, 0);
}
if(down && !up){
$(siteA).animate({'top':'-=10'}, 0);
}
I want the “10” to actually be replaced with the variable speed. So I can change it at will. How do I do it?
Simply concatenate your string: