tags:

views:

32

answers:

2

What does scrollLeft() function of jquery do? What does it mean when I write $(window).scrollLeft(),$(window).scrollLeft(1300), $("div.test").scrollLeft() and $("div.test").scrollLeft(1000)?

+1  A: 

Refer to this link.

Manie
The above link will answer your questions.
Manie
yeah, the problem is I couldn't understand what the documentation is trying to say..... :-(
Night Shade
+1  A: 

I'm assuming you're talking about the CSS .scrollLeft() method?

Description: Get the current horizontal position of the scroll bar for the first element in the set of matched elements.

The horizontal scroll position is the same as the number of pixels that are hidden from view above the scrollable area. If the scroll bar is at the very left, or if the element is not scrollable, this number will be 0.

In other words, it tells you and lets you set how many pixels the page (or an element) is scrolled horizontally.

deceze
does that mean if I call $("div").scrollLeft(200), all the divs will get scrolled horizontally by 200 pixels?
Night Shade
@Sayem Yes, if these divs are scrollable (have a scrollbar).
deceze
How can I make a div scrollable?
Night Shade
@Sayem Apply some fixed width of {x} pixels and `overflow: auto` or `overflow: scroll` and insert content that is wider than {x} pixels.
deceze
hmm, got it...could you tell me what will happen when I call $(window).scrollLeft(1300)?
Night Shade
You know, at this point you should just try it yourself.
deceze
he he...you are right. Anyway thanks a lot...talking with you has given me a more clear picture.
Night Shade