How to show / hide multiple elements at the same time with javascript

前端 未结 5 1306
礼貌的吻别
礼貌的吻别 2021-01-22 01:20

So, I have this between my head tags



        
5条回答
  •  一生所求
    2021-01-22 01:59

    The JavaScript is executed before the divs are in the DOM. The standard way to do something after the DOM is ready is to use jQuery's $(document).ready(function () { });, but there are other ways as well.

    The oldschool way is to use .

    Here's a newer way (edit: put display:none into CSS):

    HTML:

    hello

    CSS:

    .javascript_needed {display:none;}
    

    JavaScript:

    ​$(document).ready(function () {
        $('.javascript_needed').show();
    });
    ​
    

提交回复
热议问题