How to run a function when the page is loaded?

前端 未结 9 1693
小鲜肉
小鲜肉 2020-11-22 11:02

I want to run a function when the page is loaded, but I don’t want to use it in the tag.

I have a script that runs if I initialise it in th

9条回答
  •  天命终不由人
    2020-11-22 11:42

    Taking Darin's answer but jQuery style. (I know the user asked for javascript).

    running fiddle

    $(document).ready ( function(){
       alert('ok');
    });​
    

提交回复
热议问题