How to add onload event to a div element

前端 未结 24 2295
谎友^
谎友^ 2020-11-22 00:26

How do you add an onload event to an element?

Can I use:

for t

24条回答
  •  青春惊慌失措
    2020-11-22 00:37

    Try this.

    document.getElementById("div").onload = alert("This is a div.");
    Hello World

    Try this one too. You need to remove . from oQuickReply.swap() to make the function working.

    document.getElementById("div").onload = oQuickReplyswap();
    function oQuickReplyswap() {
    alert("Hello World");
    }

提交回复
热议问题