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-
Now write below code to get the element position -
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*/
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-