제이쿼리 스크롤이벤트 질문합니다 채택완료

<!DOCTYPE html>

<html lang="ko">

<head>

    <meta charset="UTF-8">

    <title>스크롤</title>

    <script src="http://code.jquery.com/jquery-latest.min.js"></script>

    <style>

        body {margin: 0;padding: 0}

        #box1 {width: 100%;height: 1000px;background: red}

        #box2 {width: 100%;height: 2000px;background: blue}

        #box3 {width: 100%;height: 100px;background: green}

    </style>

    <script></script>

</head>

<body>

    <div id="box1"></div>

    <div id="box2"></div>

    <div id="box3"></div>

</body>

</html>

 

마크업은 위코드입니다.

원하는 이벤트는 스크롤위치가 0일때(맨위) 마우스스크롤을 한칸 내리면 #box2로 스르륵 이동되게 하고싶습니다. (스크롤이 맨위가 아닌 다른곳에선 자유롭게 스크롤)

답변 1개

채택된 답변
+20 포인트

box1 에 scroll event를 걸어서 스르륵 animation을 주시면 됩니다..! 


$('#box1').scroll( function() {

$('#box2').animate();  

});


이런 형태겠네요

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고