Skip to content

Instantly share code, notes, and snippets.



Last active Oct 14, 2018
What would you like to do?
padrino blog tutorial application js
document.addEventListener('DOMContentLoaded', function () {
// Get all "navbar-burger" elements
var $navbarBurgers ='.navbar-burger'), 0);
// Check if there are any navbar burgers
if ($navbarBurgers.length > 0) {
// Add a click event on each of them
$navbarBurgers.forEach(function ($el) {
$el.addEventListener('click', function () {
// Get the target from the "data-target" attribute
var target = $;
var $target = document.getElementById(target);
// Toggle the class on both the "navbar-burger" and the "navbar-menu"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment