How to get the the (X,Y) positions of a HTML element?

Is there a way to retrieve the position (X,Y) of an HTML element?


  • DavidMDavidM USA
    edited February 2014

    You can use the .position() function of JQuery.

    From the official documentation,

      div {
        padding: 15px;
      p {
        margin-left: 10px;
      <script src="//"></script>
    var p = $( "p:first" );
    var position = p.position();
    $( "p:last" ).text( "left: " + position.left + ", top: " + );
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion