jQuery - accordion open item individually

Asked

Viewed 1,116 times

0

How to configure the plugin accordion of jquery-ui so that when I click on some item it does not close the others, for example when I click it opens the clicked and closes the others but I want when I click on some that is open remains open, how do I do it?

Code to date:

<script>
    $(function () {
        $("#accordion").accordion();
    });
</script>
<div id="accordion">
    <h3>Section 1</h3>
    <div>
        texto 2
    </div>
    <h3>Section 2</h3>
    <div>
        texto 1
    </div>
</div>
  • 1

    What’s wrong with the question? please who gave the downvote tell me how I can improve the question :)

1 answer

2


I would say that if you don’t want to close the other sections then you don’t need the accordion...

Instead of an accordion you can do so, and save loading one more .js

CSS:

#accordion div {
    display: none;
}

jQuery:

$(function () {
    $('#accordion h3').on('click', function () {
        $(this).next().slideToggle();
        return false;
    });
});

http://jsfiddle.net/k63k5/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.