Languages
[Edit]
EN

JavaScript - add onload event to div

3 points
Created by:
Violetd
925

In this article, we would like to show you how to add onload event to div using JavaScript.

Quick solution:

You can't. However, you can add <script> tag performing some action right after the <div> to be executed immediately.

 

Practical example

Edit

In this example, we get the element's offsetHeight property value right after the element is ready in the document body.

 

References

Edit
  1. HTMLElement.offsetHeight - Web APIs | MDN
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join