Add Class to Object on Page Load

后端 未结 2 1614
暗喜
暗喜 2020-12-16 04:49

Basically I want to make this:

  • About
  • Into this when the page loads:

    &l         
    
    
            
    2条回答
    •  陌清茗
      陌清茗 (楼主)
      2020-12-16 05:15

      This should work:

      window.onload = function() {
        document.getElementById('about').className = 'expand';
      };
      

      Or if you're using jQuery:

      $(function() {
        $('#about').addClass('expand');
      });
      

    提交回复
    热议问题