Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: scroll window left?
06-14-2012, 03:05 PM #1
- Join Date
- Mar 2012
- Thanked 0 Times in 0 Posts
scroll window left?
How do I scroll the window left by 90px
I can get the value of the current position by
var s = $(window).scrollLeft();
I thought $(window).scrollLeft() += 90 ;
Is this possible to animate?
06-14-2012, 03:50 PM #2
- Join Date
- Jun 2008
- New Jersey
- Thanked 259 Times in 256 Posts
Like with pretty much all of jQuery, scollLeft() is a function, not a variable, easily indicated by the parenthesis, so giving it a value means nothing.
It took only a few seconds to look at the documentation to see that scollLeft takes a value, so yes, you can scroll left, by giving it the value you want it to be at. And given that, it should work with animate() (read the animate documentation to be sure).
I'm not sure what format scollLeft returns, so if its not a number, you'll have to do a substring or something similar to get what you want.Code:curPos = Number($(window).scrollLeft()); $(window).scrollLeft(curPost + 30);
Users who have thanked Keleth for this post: