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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -