Toggle all accordion functionality using Link or Button

I have an accordion that works great. I am trying to find a way to find all the flaps of the accordion:

Find string on page (Ctrl + F) when using jQuery accordion

I used the destroy method by reference and then reinitialized to another link, but it would be great to switch this with a single button. ((I initially asked this question without this solution, so the answer below is just me. I will not accept it until I see if there are any better solutions))

$(document).ready(function() {
    $("#hide").click(function() {
        $(".accordion").accordion("destroy");
    });

    $("#show").click(function() {
        $(".accordion").accordion({
            navigation  : true,
            collapsible : true,
            heightStyle : "fill",
            active      : 
        });
    });
});

jQuery toggle(), . , , div , , , - JavaScript .

, , , , .accordion, - . , .

, , :

$(document).ready(function() {
    $("#hide").click(function() {
        $("#accordion").removeClass(".accordion");
    });

    $("#show").click(function() {
        $("#accordion").addClass(".accordion");
    });
});

, , remove , .

0
2

destroy , ( ):

$(document).ready(function() {
    $("#hide").click(function() {
        $(".accordion").accordion("destroy");
    });

    $("#show").click(function() {
        $(".accordion").accordion({
            navigation  : true,
            collapsible : true,
            heightStyle : "fill",
            active      : 
        });
    });
});

CSS, , , .

, . :

$("#show").click(function() {
    location.reload();
});
0

- . , :

// event to destroy accordion and make it content searchable
$("#open-1").on("click",function() {

    // if the button says Enable reload to bring the accordion back
    if ($(this).html() == "Enable") {
        location.reload();
    }

    // otherwise destroy the accordion and change the button to Enable
    else {
        $("#accord-1").accordion('destroy');
        $(this).html("Enable");
    }
});

. , "" "", . , . .

0

All Articles