How to get the element position using jquery ?


                     
                          Today I would like to post something related to jquery. The topic is “How you can get the element position using jquery?”. Recently I came across some jquery plugin customization and had to get the current element position and based on that getting value from the li. So let me show you how can you get the element position and retrieving it’s value from it.
First include the jquery framework library in your page in order to work with jquery. If you have in local you can just include it else you can directly include from online library as below-

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>

Now write below code to get the element position -

<script type="text/javascript">
     $(function(){
       /*Declare variables*/
        var el;
        var elposition;
        var current;

        el = $("#your-element-id");  /*Get your element object and store into variable*/

        elposition = el.position();

        console.log("Left position of your element - "+elposition.left); /*In order to display in firebug console or you can alert also.*/

        console.log("Top position of your  element - "+elposition.top);

        current = elposition.left+' , '+ elposition.top; /*Get the current position of your element i.e x,y*/

        console.log(el.val());/*Get your element value*/

    });

</script>

           Hope this post will help you all to get the element position using jquery. Will bring you some interesting post in future, keep visiting for interesting post here. Hope you all like my posts and helps you. Don’t forget to give a small like and share it in social networks above.


You can also join my technical groups and stay updated, You can simply click on the follow us links below-  
                               
Follow Us On Facebook Open Source Web Developers by Appsntech facebook group Twitter Open Source Web Developers by Appsntech twitter group Google+ Open Source Web Developers by Appsntech Google group Linkedin Open Source Web Developers by Appsntech, LinkedIn group
Copyright @2011-2015 appsntech.com. All rights reserved. Powered By- Sanjoy Dey Productions