kkkkk
kkkkk

Reputation: 716

Toggling a menu in bootstrap

I am using this bootstrap: http://blackrockdigital.github.io/startbootstrap-simple-sidebar/ I want to change a text on the button "Toggle menu". I want to have a text "show menu", "hide menu". I only found this fragment a code, but I am able to change a name only once. I don't know how to do the second text "show menu" (when the side bar id hidden).

<a href="#menu-togglemenu-toggle" class="btn btn-default" id="menu-toggle">Hide Menu</a>

Upvotes: 0

Views: 33

Answers (1)

Nicolapps
Nicolapps

Reputation: 988

Replace the actual JavaScript code by this code :

$("#menu-toggle").click(function(e) {
    e.preventDefault();
    if($('#wrapper').hasClass('toggled')){
        $(this).html('Hide menu');
    } else {
        $(this).html('Show menu');
    }
    $("#wrapper").toggleClass("toggled");
});

Upvotes: 1

Related Questions