Reputation: 45
I want to add an amount of pixels, that is stored in my variable "x" to a css property in jQuery.
I know that since jQuery 1.6 you can easily use something like this:
$(this).css({top: "+=150"});
But when I use a variable instead of the 150 it doesn't work, since variables have to be written out of quotation marks.
$(this).css({top: "+= x"});
Upvotes: 0
Views: 134
Reputation: 797
Please try this
$(this).css({top: "+= "+ x +"px"});
instead of your code
Upvotes: 1