Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • jQuey scrollTop()

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 131
    Comment on it

    this method is used to set the position of vertical scroll bar for a particular element.

    0 Position of scrollbar means it is at the Top.

    In a web page, when ever we want to adjust the scrollbar according to its content, we make use of this  method.

    It takes the position of scrollbar to the top for clear visibility of content for a particular web page

    Syntax:

    $(selector).scrollTop() 

     

    Example:

    <!DOCTYPE html>  
    <html>  
    <head>  
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>  
    <script>  
    $(document).ready(function(){  
        $("button").click(function(){  
            alert($("div").scrollTop() + " px");  
        });  
    });  
    </script>  
    </head>  
    <body>  
    <div style="border:1px solid black;width:150px;height:100px;overflow:auto">  
    Evon tech located  at it park in Dehradun   
    Twinkle, twinkle, little star, How I wonder what you are!</div><br>  
    <button>Return the vertical position of the scrollbar</button>  
    <p>Move the scrollbar down and click the button again.</p>  
    </body>  
    </html>  

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: