How to add onload event to a div element

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

    Use the body.onload event instead, either via attribute ( ...) or by binding an event in Javascript. This is extremely common with jQuery:

    $(document).ready(function() {
        doSomething($('#myDiv'));
    });
    

提交回复
热议问题