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)