# Close the mobile menu after a link is tapped

> In this document, we will go over how to use custom JavaScript to auto-close a menu bar while on mobile.

Source: https://tadabase.com/docs/learn/auto-close-mobile-menu  
Status: Not yet re-checked. Moved from our previous help site and not yet re-checked against the current product. Last edited Sep 20, 2024.

In this document, we will go over how to use custom JavaScript to auto-close a menu bar while on mobile.

Here's how that will look

![Screenshot for “Auto close mobile menu”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2020-03/ZPQUYWeJ2U7leTGczD3H1VqO1XWdfbvDwA.gif)

Simply add the following JavaScript to the Layout the menu is located in. In our example, this menu is located in the Default Layout

```javascript
$('.navbar .item').on("click",function(){
    $(".navbar-collapse").collapse('hide');
});

$('.nav .item.dropdown-submenu').unbind();
```

![Screenshot for “Auto close mobile menu”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2020-03/scaled-1680-/WVAC0HfdCo6_bXxXxiy5Dotcd5yiLOeuHw.png)
