Wednesday, January 26, 2011

How to get and set coordinate for html element by JQuery offset()

How to get and set coordinate for html element by JQuery offset()
Codes example:
Get
var p = $("p:last");
var offset = p.offset();
p.html( "left: " + offset.left + ", top: " + offset.top );</script>


Set:
<script>$("p:last").offset({ top: 10, left: 30 });</script>


Reference:

No comments:

Post a Comment