The mobile menu is not responding to the click event

Upon clicking the mobile menu hamburger button, I am experiencing a lack of response. I expected the hamburger menu to transition and display the mobile menu, but it seems that neither action is being triggered.

Even though I can confirm that my javascript file MobileMenu.js is being accessed, the .click() event does not seem to be working as there is no reaction. While I do receive a console log message saying "Got into the MobileMenu!", I do not see the "You clicked it!" message from within the event either. Additionally, the css transition for the hamburger menu to change to an X does not occur.

There are no errors showing up in the console log or during my gulp build or watch processes. All of my packages are also up-to-date. I have been troubleshooting this issue for some time now and would greatly appreciate another pair of eyes to spot anything that I might be missing.

Thank you!

MobileMenu.js


console.log("Got into the MobileMenu!");

class MobileMenu{
    constructor() {
        this.menuIcon = $(".site-header__menu-icon");
        this.siteHeader = $(".site-header__nav");
        this.menuContent = $(".site-header__btn-container");
        this.events();
    }

    events() {
        this.menuIcon.click(this.toggleTheMenu).bind(this);
    }

    toggleTheMenu() {
        console.log("You clicked it!");
        this.siteHeader.toggleClass("site-header--is-expanded");
        this.menuContent.toggleClass("site-header__menu-content--is-visible");
        this.btnContent.toggleClass("site-header__btn-container--is-visible");
    }
} 

export default MobileMenu;

HTML

    <div class="site-header__menu-icon">
      <div class="site-header__menu-icon__middle"></div>
    </div>

    <ul class="site-header__logo" role="navigation">
      <li class=""><a href="/"><h2>Logo name</h2></a></li>
    </ul>
    <ul class="site-header__nav">
      <li class="site-header__nav--item"><a href="#about">About Me</a></li>
      <li class="site-header__nav--item"><a href="#what">What I Do</a></li>
      <li class="site-header__nav--item"><a href="#portfolio">Portfolio</a></li>
    </ul>
    <ul class="site-header__btn-container">
      <li>
        <a href="#" class="btn btn__nav btn--orange open-modal">Get in Touch</a>
      </li>  
    </ul>
  </header>

CSS - some

    position: absolute;
    width: 100%;
    z-index: 2;
    font-family: 'Aclonica', sans-serif;
    padding-bottom: 20px;

    &--is-expanded {
        background-color: rgba($mainBlue, .55);
    }

    @mixin atMedium {
        display: flex;
        position: fixed;
        height: 65px;
        padding-top: 4px;
        background-color: rgba($mainBlue, .9);
        transition: background-color .3s ease-out;
        list-style: none;
        color: #fff;

        &--dark {
            background-color: rgba(23, 51, 72, .85);
        }

    }

My expectation is that upon clicking the menu button, the mobile menu will be visible and the menu content will populate.

Answer №1

Update: After thorough investigation, I learned that the issue stemmed from the build process rather than the code itself. It appears that the scripts were not compiling correctly. I appreciate all the suggestions provided nonetheless.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Every time I restart VSCode, I have to re-run the .zsh_profile command in order for the NVM packages to work properly

Many others have encountered a similar issue, but I'm struggling to resolve it. Every time I open VSCode, I find myself needing to run these commands in the terminal for npx, npm, and nvm to work: export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] ...

Workbox background sync - Retrieving replayed API responses

Currently, I am utilizing the Workbox GenerateSW plugin and implementing the backgroundSync option within runtimeCaching. You can find more information in the documentation here. This powerful plugin enables me to monitor APIs and successfully retry faile ...

The art of styling <li> elements compared to <a> elements

While these inquiries may lean towards being subjective, I am interested in learning about the industry's generally accepted best practices: 1) With responsive design and collapsible menus becoming more common, should a nav or nav menu element be sty ...

Not motivated to write HTML content

Recently, I've been utilizing the lazySizes plugin for optimizing my images. However, I encountered an issue when trying to implement it for HTML content display. Is there a simpler way to achieve this and maintain my current HTML structure? $(&apo ...

Incorporating a JavaScript variable into an inline HTML onclick event

Having trouble passing a variable into an inline onclick function. I've tried researching and following suggestions from this link, but encountered errors (Uncaught SyntaxError: missing ) after argument list): pass string parameter in an onclick func ...

What is preventing me from being able to spyOn() specific functions within an injected service?

Currently, I am in the process of testing a component that involves calling multiple services. To simulate fake function calls, I have been injecting services and utilizing spyOn(). However, I encountered an issue where calling a specific function on one ...

Creating a static footer in AngularJS with material design: A step-by-step guide

This is how I've set up my webpage design. <div layout="column" layout-fill ng-controller="MainCtrl as mc"> <header> <md-toolbar md-scroll-shrink> <div layout="row" layout-align="center center" flex> ...

Is it secure to utilize sessions in a WordPress plugin?

I am currently working on a WordPress plugin that requires transferring large amounts of data via AJAX to a PHP file for processing, which will then trigger a file download based on the data. However, I have encountered an issue where the force download fu ...

JQuery method for altering currentTime's format

I am attempting to showcase the current time and duration of my videos on my website using the format 00:00, but I am having some difficulty... myVideo.on('timeupdate', function() { $('.current').text(myVideo[0].currentTime); $ ...

Is the execution of promises in Node.js synchronous or asynchronous?

There is a lot of confusion regarding promises. Are they synchronous or asynchronous? return new Promise (function(resolved,reject){ //Is this operation synchronous or asynchronous? }); ...

Ways to retrieve Data obtained in response using superagent

I am currently working on hitting an API and extracting the data received in response. To achieve this, I am utilizing superagent to retrieve the data from the API. I have inspected my network tab, however, I am encountering an issue where I want to extra ...

Enable a single column to scroll until the content is fully displayed, and then stay in a fixed position

My HTML content consists of two columns, with the first column being a sidebar that should have limited content. The second column holds the main content and can span several pages. The desired functionality is for the first column to scroll until the end ...

The event tooltip in fullcalendar does not show up as expected

Within my Laravel 5.8 / Bootstrap v4.1.2 / jQuery jQuery v3.3.1 fullcalendar v4.3.1 application, I am attempting to incorporate tooltips for events in the fullcalendar plugin. To achieve this, I referred to a specific example provided here: Sample Example ...

using the information from the child array within a v-if condition

I'm struggling to extract data from a child array and utilize it in my v-if condition. Below are my data and code. Any assistance would be appreciated, even if it's just pointers to the right documentation. <div class='post' v-for= ...

What is the best method to add data to a child array located within a nested array?

Struggling to create an array that will display data in the following format: Healthcare -- Insights driven by data for improved healthcare -- Urban Analytics Transport -- Urban Analytics Cities -- Urban Analytics I have attempted ...

Display images with sequential animation and a delay, combining fade-in and slide-up effects

I am attempting to create a cycling image display with specific effects: There should be a one-second delay before the first image is shown. The first image will appear with a fade-in and slide-up effect. Image #1 will remain visible for 5 seconds before ...

React Type Mutation response feedback is a valuable tool for receiving input

I am facing an issue with passing the mutation success response in my code. I have a file named change-email.tsx which calls a component file updateEmail.tsx containing a mutation function. The submit function is working fine, but I cannot figure out how t ...

Invoking res.download() in the Express framework

It's puzzling why this issue is occurring, and it's quite frustrating. I was expecting the file to be downloaded in line with the guidelines provided in the Express documentation. Below is the code snippet I am using: //within React (App.js) ...

PHP variable inaccessible

When using JQuery Ajax to call sessions variables from a PHP steamauth file, I encountered an issue. Even though the code works fine when "$data['test'] = "ok";" is used instead of "$data['test'] = $_SESSION['steamid'];", ther ...

Is it common to encounter a "no such file or directory" error when running Docker-Compose with the command "ENTRYPOINT ['./init.sh']" in a Dockerfile?

Contemplate the docker-compose configuration : version: '3.0' volumes: data: driver: local networks: simple-network: driver: bridge services: postgres: container_name: postgres image: postgres ...