How do I hide an HTML element before the page loads using jQuery

前端 未结 7 1325
独厮守ぢ
独厮守ぢ 2020-12-07 20:44

I have some JQuery code that shows or hides a div.

$(\"div#extraControls\").show();   // OR .hide()

I initially want the div to be not visi

7条回答
  •  死守一世寂寞
    2020-12-07 21:29

    The best way to load javascript function over page is loaded, is

    $(window).bind("load", function() {
       // code here
    });
    

    In your case

    div.hidden
    {
       display: none
    }
    
    
    
    $(window).bind("load", function() {
       $("div#extraControls").removeClass("hidden");
    });
    

提交回复
热议问题