Will the element be visible even for a blink of an eye If it is added to DOM and instantly removed?
var feed = $('<div class="entry"></div>').text(data.status).appendTo(app.twitter_feed);
console.log(feed.height());
feed.remove();
I’ve tried the above code on a few browsers and couldn’t see the element. But is this behaviour consistent through all platforms/browsers?
After reading your previous question as well, it seems that you very badly want to calculate the display height of an element before actually displaying it. I ‘m not entirely clear why you want to do this (it gives off a bad smell), but here’s how to anyway.
Put a
<div>in your page withheight: 0,overflow: hidden, and the desired width of your element¹. Add the<div>we ‘re talking about inside that outer helper div (it will not show no matter what), and get its height after the browser performs layout. After that you can proceed however you want (e.g. by moving the inner<div>to another position in the DOM tree).¹ it would be best to put it exactly where you want the
.entryto end up (i.e. the.entryand the helper div will end up being siblings).PS: It’s always better for everyone if you mention your real purpose.