When can I read attributes such as offsetWidth of DOM elements

after you create a dom element in a javascript script and add it to the document with appendChild, when can you read attributes such as offsetWidth of the element?

the values of reading these attributes are all 0 before the element is rendered, so is there a timing or callback function to let me know that these attributes are valid?

like the hook function componentDidMount, in React, you can know exactly that the element has been rendered. What is its principle?

Thank you.

Apr.02,2021
After the

appendChild operation


appendChild is executed, the DOM can be read normally.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31c3d-2bdd3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31c3d-2bdd3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?