jQuery添加可折叠面板

时间:2013-02-20 12:54:40

标签: jquery

使用jQuery我想动态添加新的可折叠面板。手风琴是不够的,因为我需要一次打开一个以上的部分。

样本here正是我所需要的,除了我想要一个按钮点击动态添加新面板。

使用.append()添加新标记不起作用。我不介意解决方案是否包含插件或其他任何东西(我不想使用像'KendoUI'这样的框架)

1 个答案:

答案 0 :(得分:0)

jQuery documentation

所示
  

手风琴不允许打开多个内容面板   同时,这需要付出很多努力。如果你是   寻找允许多个内容面板的小部件   打开,不要用这个。通常它可以写几行   相反,jQuery,像这样:

jQuery(document).ready(function(){
  $('.accordion .head').click(function() {
      $(this).next().toggle();
      return false;
  }).next().hide();
});
Or animated:

jQuery(document).ready(function(){
  $('.accordion .head').click(function() {
      $(this).next().toggle('slow');
      return false;
  }).next().hide();
})