Is it possible to get the height of a cloned jQuery object?

JQuery example:

$('document').ready(function(){
    var $theP = $('p');
    var $theDiv = $('div');
    $theP.html($theP.html() + "<br>div height: " + $theDiv.outerHeight());
    var $theClone = $theDiv.clone();
    $theP.html($theP.html() + "<br>clonded div height: " + $theClone.outerHeight());
})

Direct link: http://jsbin.com/odujiv/4

When doing the above, you get the result "0" when you try to get its height. I think this is because the cloned object has not yet been placed in the DOM. The only way to get the height is to first add the cloned element back to the DOM? If so, I think it is doable, but it would be great to handle this before I put it back in the DOM.

+5
source share
2 answers

, . HTML , , jQuery . , , HTML!

+4

:

$theClone.height();

or

$theClone.css('height');
-1

All Articles