Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2012
    Posts
    60
    Thanks
    65
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,537
    Thanks
    45
    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).

    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.

  • Users who have thanked Keleth for this post:

    code-in-time (06-15-2012)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •