jQuery: using variable in animate for left continuous update -
var shiftleft = -250; setinterval(function(){ $("ul")animate( { left: '-=250' }, 500); }, 2000); here, in above code code need shiftleft variable used in animate function instead of -=250.
try this:
var shiftleft = -250; var shiftleftstr = shiftleft.tostring(); var = shiftleftstr.substr(0, 1); var b = shiftleftstr.substr(1); var animatepx = + "=" + b; setinterval(function(){ $("ul").animate( { left: animatepx }, 500); }, 2000); so, first make string. after use substr first char, , after remaining chars.
and after all, put pieces together.
Comments
Post a Comment