How to add onload event to a div element

前端 未结 24 2652
谎友^
谎友^ 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

    The onload event can only be used on the document(body) itself, frames, images, and scripts. In other words, it can be attached to only body and/or each external resource. The div is not an external resource and it's loaded as part of the body, so the onload event doesn't apply there.

提交回复
热议问题