2012-04-20 100 views

回答

1
var cloned = $("#itemtoclown").clone(); //clone an element 
$("body").append(cloned); //Insert it into DOM 

//Access the positions like with 
var positions = cloned.position(); 
console.log(positions.top); //Access the top 
0

爲了得到一些元素的位置必須附加到HTML DOM樹。否則,你會得到最高:和左:

$(document).ready(function(){ 
    position = $('div:first').clone().appendTo(document.body).position(); 
    alert('top:' + position.top + ' left: ' + position.left); 
}); 

jsFiddle example