超级简单的jQuery选项卡 - 没有UI - 在页面加载时崩溃

时间:2016-05-13 14:20:45

标签: javascript jquery tabs accordion

我希望在页面加载时折叠所有标签页。现在,第一个默认是打开的:

  $(document).ready(function($) {
    $('#forms').find('.forms-toggle').click(function(){

      //Expand or collapse this panel
      $(this).next().slideToggle('fast');

      //Hide the other panels
      $(".forms-content").not($(this).next()).slideUp('fast');

    });
  });

HTML和CSS在这里:

https://jsfiddle.net/re8x8cx3/

2 个答案:

答案 0 :(得分:0)

将它放在dom中,

 $(".forms-content").hide();

然后代码将是,

$(document).ready(function($) {
  $(".forms-content").hide();
  $('#forms').find('.forms-toggle').click(function() {
    //Expand or collapse this panel
    $(this).next().slideToggle('fast');
    //Hide the other panels
    $(".forms-content").not($(this).next()).slideUp('fast');
  });
});

Fiddle

答案 1 :(得分:0)

还请你改进JS:

<?php
            $files = glob('/images/pic/sound/*.mp3');
                for ($i=0; $i<count($files); $i++)
                {
                $num = $files;
                echo date ("F d Y H:i:s.", filemtime($num))."<br><br>";
                echo '<audio src="'.$num.'" autostart="true" loop="infinite"></audio>'."<br><br>";

                }


            ?>