position of div

by Chandana Thota

HTML

<!-- Display position of div in the screen-->

<div id="first"></div>

CSS

#first{
    background-color:blue;
    height:100px;
    width:100px;
}

JavaScript

$(document).ready(function(){
var pos = $('#first').position();
    alert("position from left: " + pos.left  + "                         Position from top :" + pos.top );
});