jquery ui accordion avoid closing item wnen clicking on another one

后端 未结 4 1887
夕颜
夕颜 2021-01-03 12:35

starting from existing fiddle, I\'ve created this sample: http://jsfiddle.net/2DaR6/90/

Here\'s the html code:

相关标签:
4条回答
  • 2021-01-03 12:46

    $(".xyz").accordion({ collapsible: true,
    active: false, heightStyle: "content", icons:"", });

    0 讨论(0)
  • 2021-01-03 12:49

    I agree that accordion probably isn't the best plugin to use, BUT you could do the following:

    You could change from using an id and use accordion as a class, and then have multiple div to break your sections up.

    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script>
          $(function() {
            $( ".accordion" ).accordion({collapsible: true, active: false});
          });
    </script>
    <div class="accordion">
      <h3>header 1</h3>
      <p>this is my content 1</p>
    </div>
    
    <div class="accordion">
      <h3>header 2</h3>
      <p>this is my content 2</p>
    </div>

    0 讨论(0)
  • 2021-01-03 12:51

    May be do you need another plugin collapse/expand? For example this (see the example of the bottom of page)

    0 讨论(0)
  • 2021-01-03 12:57

    You should not use jquery accordion for this kind of purpose. However, its relatively easy to override any element events behaviour. When accordion is initialized, you just have to override click handler to corresponding elements.

    In your case, this giving something like this:

    $('#accordion .accClicked')
            .off('click')
        .click(function(){
            $(this).next().toggle('fast');
        });​
    

    See working jsFiddle

    0 讨论(0)
提交回复
热议问题