달력

32024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
Posted by tornado
|

[출처] http://stackoverflow.com/questions/832860/how-to-scroll-the-window-using-jquery-scrollto-function

 

 

Hi,

I'm trying to scroll down 100px every time the user gets near the top of the document.

I have the function executing when the user gets close to the top of the document, but the .scrollTo function isn't working.

I put an alert after and before to check to see if it actually was the line or not that was stopping it and only the first alert goes off, here's the code:

alert("starting"); 
$.scrollTo({ top: '+=100px', left: '+=0px' }, 800); 
alert("finished"); 

I know I have the jquery page linked properly because I'm using many other jquery functions throughout and they all work fine. I've also tried removing the 'px' from above and it doesn't seem to make a difference.

flag
Don't you have a JavaScript debugger? – Matthew Flaschen May 7 at 4:17
1  
Jquery itself my be working fine, but are you sure you have the scrollTo plugin linked properly? Change one of those alerts to alert($.scrollTo); – Andrew May 7 at 5:03

2 Answers

vote up 6 vote down check

If it's not working why don't you try using jQuery's scrollTop method?

$("#id").scrollTop($("#id").scrollTop() + 100); 

If you're looking to scroll smoothly you could use basic javascript setTimeout/setInterval function to make it scroll in increments of 1px over a set length of time.

'DHTML > Javascript' 카테고리의 다른 글

jquery block ui.....  (0) 2010.08.06
[jquery] AD-Gallery Image Slider...  (0) 2010.03.17
[펌] HTML 객체의 절대 좌표 구하기.  (0) 2009.09.25
JQuery 로 시간을 선택한다. TimePicker 2종류  (0) 2009.09.03
http://visualjquery.com/  (0) 2009.08.05
Posted by tornado
|