How to add onload event to a div element

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

How do you add an onload event to an element?

Can I use:

for t

24条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 01:02

    I needed to have some initialization code run after a chunk of html (template instance) was inserted, and of course I didn't have access to the code that manipulates the template and modifies the DOM. The same idea holds for any partial modification of the DOM by insertion of an html element, usually a

    .

    Some time ago, I did a hack with the onload event of a nearly invisible contained in a

    , but discovered that a scoped, empty style will also do:

    .....

    Update(Jul 15 2017) - The