I created a new div element in JavaScript and I appended some text content. Now I required to get the height of the div which was created in the JavaScript.
Sample code:
const str = 'One of the important elements of a web application is form processing and file uploads. PHP has excellent support for these kind of things which makes it so popular with developers.';
const container = document.createElement('div');
container.style.width = '1020px';
const textContent = document.createTextNode(str)
container.appendChild(textContent);
const width = container. ??? // Should be in number like container.clientHeight
const height = container. ???
The text content will grow based on the topics. How could I get the height and width of the virtual div element without loading in HTML DOM.
Note: I'm not added the div in the real html document. Just created in the javascript and I'm converting the div to PDF for doing this I required the height and width of the div.
Kindly assist me how to do this.