Answer the question
In order to leave comments, you need to log in
How to get the width of an element that is outside the DOM?
In general, I create an element elem = $("<div />");
and add text to it elem.text("Блаблабла");
.
And now, when there is text in it, its width is supposedly increased, but it elem.width()
returns 0.
Ps: I need to fix the current width so that when the element is added to the DOM, the text inside this element changes, but the element itself does not become larger than was originally with the first text. How to solve the problem?
Answer the question
In order to leave comments, you need to log in
You can fix the width at the CSS level, for example max-width. Or for example overflow: hidden; (overflow-x, overflow-y). The question is not entirely clear, therefore a vague answer.
And an element outside the DOM has no width, i.e. at all.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question