How can i get height and width of element which doesn’t a part of DOM yet?
For example:
var t = $('<div style="position:absolute;height:100px;width:100px;background-color:steelblue;" >lalala</div>');
var height = t.height(); // height is 0!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Works for me as well. You could try
though as demonstrated in this fiddle.
If that doesn’t work for you (well possible depending on the browser), consider temporarily adding the element to the DOM: