S
S
SpideR-KOSS2018-10-10 11:22:14
css
SpideR-KOSS, 2018-10-10 11:22:14

Why doesn't the Bulma menu burger work on my phone?

Good afternoon!
I made Bulma menu burger according to official documentation.
In the browser everything works fine, but on the phone (iPhone 4s) it does not appear at all. You click on the opening, it opens in the browser, but nothing happens on the phone.
Here is the code.

<a role="button" class="navbar-burger" data-target="navMenu" aria-label="menu" aria-expanded="false">
     <span aria-hidden="true"></span>
     <span aria-hidden="true"></span>
     <span aria-hidden="true"></span>
</a>

<div class="navbar-menu" id="navMenu">

      <a class="navbar-item">
          Пункт 1
       </a>

       <a class="navbar-item">
          Пункт 2
       </a>

       <a class="navbar-item">
          Пункт 2
       </a>
</div>

<script type="text/javascript">
    document.addEventListener('DOMContentLoaded', () => {

        // Get all "navbar-burger" elements
        const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);

        // Check if there are any navbar burgers
        if ($navbarBurgers.length > 0) {

            // Add a click event on each of them
            $navbarBurgers.forEach(el => {
                el.addEventListener('click', () => {

                    // Get the target from the "data-target" attribute
                    const target = el.dataset.target;
                    const $target = document.getElementById(target);

                    // Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
                    el.classList.toggle('is-active');
                    $target.classList.toggle('is-active');

                });
            });
        }

    });
</script>

Styles are standard.
What is the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question