Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Get the current position of element using jquery

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 269
    Comment on it

    Welcome to FindNerd.
    We are going to describe the functions to get the current position of the bound element. There are two functions named offset and position. They are used as a same manner. Let's take an example of both function.

    <ul class="usersList">
    <li class="list1">Amit</li>
    li class="list2">Arun</li>
    <li class="list3">Sourav</li>
    <li class="list4">Raghav</li>
    </ul>
    <button class="curr-pos"></button>
    <script>
    jQuery('curr-pos').click(function(){
        var elementPos = $('list3').offset();
        console.log('left one:' + elementPos.left + '--top one:+ elementPos.top);
    });
    jQuery('curr-pos').click(function(){
        var elementPos = $('list3').position();
        console.log('left one:' + elementPos.left + '--top one:+ elementPos.top);
    });
    </script>
    

    In above example we are getting position of the element with the help of two different functions that are offset and position.

 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: