Load javascript before rendering page?

后端 未结 5 2103
自闭症患者
自闭症患者 2020-12-14 07:55

I want to run some jquery code before my page have loaded. Im adding some classes which are changing the css with javascript, and when the page loads i see the \"old\" css f

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-14 08:29

    Put your code in document ready. Everything inside it will load as soon as the DOM is loaded and before the page contents are loaded

    $(function(){
     your code goes here...
    });
    

    Or

    $(document).ready(function(){
     your code goes here..
    });
    

提交回复
热议问题