1

Following code:

        let textArea = document.createElement('textarea');
        textArea.value = responseTextFromXMLHttpRequest;
        $('body').append(textArea);

        console.log(textArea.scrollHeight);

Gives me this result in the CONSOLE: 34

But if I don't append the textarea to the body then I get in CONSOLE: 0

Can I make the textarea to update the height without appending it first to the document? Somehow force it?

I am asking because I create 300 textareas which I fill with text and need to know their height to style them. And I am not sure if appending them to the document just to get their height is the best way I can do it. I am afraid that appending them and afterwards removing just to get the height would take up more resources than some other method if it exist.

0 Answers0