Faustino Luna Montaner Faustino Luna Montaner - 4 months ago 13
Javascript Question

How to open programatically bootstrap mobile navbar?

I'm trying to discover the way to open the bootstrap mobile navbar when a button is clicked.

$("#myCustomBtn").click(function(){
// Magic code goes here!
});


No matters is I need to use jQuery.

Answer

The responsive navbar uses the collapse plugin, you can use a link with the href attribute, or a button with the data-target attribute of the button in your navbar. Here's an example

EDIT:

If you want to do it via jQuery you can call the collapse methods: .collapse('toggle'), .collapse('show') or .collapse('hide')

I updated the example.