jQuery > Manipulations methods

.position() - Retrieve position of element in jQuery

How to retrieve the position of an html element in jQuery?


To get the position of an html element, position() method can be used that gives the position object which can be used to determine the left and top position relative to its parent element.

 <script>
      var position = $("h1").position();
      alert(position.left + " : " + position.top);
  </script>

Above code snippet will find the position object for the “h1” element. That position object will have left and top properties that is used to retrieve its left and top position relative to its parent element.

 Views: 4562 | Post Order: 55



Write for us






Hosting Recommendations