如何在页面重新加载后隐藏内容 div

how to hide content div after page reloading

我正在使用此 javascript 折叠和展开 div,其中包含一些信息。 div 有 class .info。 页面重新加载后,你首先可以看到 div 是可见的,但一秒钟后,当 js 加载时,它消失了。 我如何在重新加载页面时实现这一点,也是第一次 div 不可见?

$( document ).ready(function() {

   var $accordionIO = $('.accordion .toggle-button');


   $accordionIO.prev('div').hide();

   $(".accordion .toggle-button").click(function () {
    //Inner 
    var jqInner = $('.info', $(this).parent());
    if (jqInner.is(":visible"))
    {
        jqInner.slideUp();
        $(this).find('.button-switch').html('Information');
    }
    else
    {
        jqInner.slideDown();
        $(this).find('.button-switch').html('Close');
    }
   });
}); 

html:

<!-- Start toggle script -->
    <div class="accordion">
        <div class="info">
          <?php
             include('includes/information.txt');
          ?>
        </div>
        <div class="toggle-button"><span class="button-switch">Information</span> </div>
    </div>

请尝试添加内联样式属性。请参见下面的示例:

<div style="display:none;"></div>