Home > Article > Web Front-end > Why Does My Bootstrap 3 Collapsed Menu Stay Open After Clicking a Link?
Problem:
In a Bootstrap 3 navigation, the collapsed menu remains open after clicking a menu link, disrupting the user experience.
Answer:
To resolve this issue, implement the following code:
$(document).on('click','.navbar-collapse.in',function(e) { if( $(e.target).is('a') ) { $(this).collapse('hide'); } });
Details:
Update [2014-11-04]:
$(document).on('click','.navbar-collapse.in',function(e) { if( $(e.target).is('a:not(".dropdown-toggle")') ) { $(this).collapse('hide'); } });
The above is the detailed content of Why Does My Bootstrap 3 Collapsed Menu Stay Open After Clicking a Link?. For more information, please follow other related articles on the PHP Chinese website!