开发者

close a section of a accordion in jquery

It's a simple question, but i don't know how do it. I think there's a way to close all of the sections in the accordion attached 开发者_Python百科to a event click, but i haven't found a method that will allow it to be done. I tried this:

$(document).ready(initialize);

$("#accordion").accordion("destroy");

$("#accordion").accordion({
    collapsible: true,
    active: false
});

function initialize() {

    $(".btnOk").click(function (e) {
    e.preventDefault();
    $("#accordion").accordion("active", false);
    }
}


I think you're looking for the activate method instead of active method. I haven't tried it, but I think you should change:

$("#accordion").accordion("active", false);

to:

$("#accordion").accordion("activate", false);

Hope this helps.


You can do it by using .accordian("activate", -1).

Check out my working jsFiddle demo:

$(function() {

    var $accordion = $("#accordion");

    $accordion
        .accordion("destroy")
        .accordion({

            collapsible: true,
            active: false

        });

    $(".btnOk").click(function(e) {

        e.preventDefault();
        $accordion.accordion("activate", -1);

    });

});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜