Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-14-2012, 03:05 PM   PM User | #1
code-in-time
New Coder

 
Join Date: Mar 2012
Posts: 59
Thanks: 65
Thanked 0 Times in 0 Posts
code-in-time is an unknown quantity at this point
scroll window left?

Hi

How do I scroll the window left by 90px

I can get the value of the current position by

Code:
var s = $(window).scrollLeft();

I thought $(window).scrollLeft() += 90 ;

Is this possible to animate?

Thanks
code-in-time is offline   Reply With Quote
Old 06-14-2012, 03:50 PM   PM User | #2
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
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).

Code:
curPos = Number($(window).scrollLeft());
$(window).scrollLeft(curPost + 30);
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.
Keleth is offline   Reply With Quote
Users who have thanked Keleth for this post:
code-in-time (06-15-2012)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:19 PM.


Advertisement
Log in to turn off these ads.