Hook a javascript event to page load

前端 未结 5 695
感情败类
感情败类 2020-12-03 10:02

I have an aspx that has the following javascript function being ran during the onload event of the body.


5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-03 10:40

    The cleanest way is using a javascript framework like jQuery. In jQuery you could define the on-load function in the following way:

    $(function() {
        // ...
    });
    

    Or, if you don't like the short $(); style:

    $(document).ready(function() {
        // ...
    });
    

提交回复
热议问题