I'm trying to set an image's left and right values randomly using JQuery by doing the following:
var sides = ["left", "right"]
var currentSide = sides[Math.floor(Math.random() * sides.length)];
$("#"+currentImage).css({currentSide : "80px"});
So i have an array that contains either 'left' or 'right' which gets randomly selected and the CSS of the element gets set to either right: "80px"; or left: 80px;
But, its not working. When I go and set it statically e.g. $("#"+currentImage).css({"left" : "80px"}); then it works fine, so it's just passing variables to the .css() function that's making this break.
Any ideas?
$("#"+currentImage).css( currentSide , "80px" );doc?