What could be causing the Contact anchor element to not function properly?

I've been working on creating a dropdown menu for my API, but I'm having trouble getting the anchor links to function properly. I even attempted changing the "a" element to an onclick call with javascript:void(0) and added a function to open Gmail, but that didn't work either. Can someone please review this code? Your input is greatly appreciated. Thank you.

Here is the code snippet:

var tmenu = document.getElementById('t-menu');
var dropdown = document.getElementById('dropdown');
var bars = document.getElementById('bars');
var navbar = document.getElementById('navbar');

function ShowMenu() {

  if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {


    if (tmenu.style.display = 'flex') {
      tmenu.style.display = 'none';
      bars.style.display = "flex";
      navbar.style.display = 'block';
    } else {

      dropdown.style.display = 'block';
      navbar.style.display = 'none';
    }

  }

}
html {
  font-family: open sans, -apple-system, BlinkMacSystemFont, segoe ui, Roboto, Oxygen-Sans, Ubuntu, Cantarell, helvetica neue, sans-serif;
  overflow-x: hidden;
}

h2 {
  font-size: 1.8rem;
}

a {
  transition: 0.7s ease-in-out;
  text-decoration: none;
}

a:hover {
  transition: 0.7s ease-in-out;
  text-decoration: underline;
}

.header-menu {
  display: flex;
  width: 100%;
  background-color: black;
}


/* Style the navigation bar */

.navbar {
  width: 100%;
  background-color: #555;
  overflow: auto;
}

header {
  position: absolute;
  inset: 0;
  width: 100vw;
}


/* Navbar links */

.navbar a {
  float: none;
  text-align: center;
  padding: 12px;
  color: white;
  text-decoration: none;
  font-size: 17px;
}


/* Navbar links on mouse-over */

.navbar a:hover {
  background-color: #000;
}


/* Current/active navbar link */

.active {
  background-color: rgba(82, 87, 247, 1);
}

.t-menu {
  display: none;
}

@media screen and (max-width: 640px) {
  .navbar {
    display: none;
    transition: 0.7s ease-in-out;
  }
  .navbar a {
    transition: 0.7s ease-in-out;
    float: none;
    display: flex;
    height: auto;
  }
  .t-menu {
    display: inline-block;
    position: fixed;
    z-index: 1;
    width: 100%;
    height: 6vh;
    background-color: #555;
  }
  .bars-icon {
    position: flex;
    text-decoration: none;
    color: white;
    font-size: 8vw;
    margin-bottom: 1vw;
    margin-left: 2vw;
  }
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" />
<header>
  <nav>
    <div class="navbar" id="navbar">
      <center>
        <a class="active" href="#"><i class="fa fa-fw fa-home">   </i>&nbsp;Home</a>
        <a href="#"><i class="fa fa-fw fa-credit-card"></i>&nbsp;Pricing</a>
        <a href="#"><i class="fa fa-fw fa-code"></i>&nbsp;API</a>
        <a href="#"><i class="fa fa-fw fa-book"></i>&nbsp;Docs</a>
        <a href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="92f7eaf3ffe2fef7d2f5fff3fbfebcf1fdff">[email protected]</a>" name="email"><i class="fa fa-fw fa-envelope"></i>&nbsp;Contact</a>
    </center>
    </div>
  </nav>
</header>
<header>
  <div class="t-menu" id="t-menu">
    <div class="dropdown" id="dropdown">
      <div onclick="ShowMenu()" class="bars-icon" id="bars">☰</div>
    </div>
  </div>
</header>

Answer №1

The second header, containing your t-menu, is overlapping with the first header menu and capturing all the click events, preventing them from reaching the a tags in the initial header. To resolve this issue, I suggest hiding the second header using either display: none or pointer-events: none when it is not in use.

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

"Troubleshooting tip: encountering a SyntaxError message stating 'import declarations may only appear at top level of a module'? Here's

After downloading fetch-jsonp by running npm i fetch-jsonp and adding its dependency to my package.json, I attempted to import it using the following code at the top of my main.js: import fetchJsonp from 'fetch-jsonp'; However, I kept encounter ...

When using QML, functions like Object.keys, Object.values, and JSON.stringify may return unexpected empty results

I have written a code that exposes a C++ object to QML, and I want to verify the declared properties of the object using native JS methods. However, they are not working as expected. I created a method called FizzBuzzDerived.properties, which functions cor ...

Tips for customizing the md-select icon

I work with the angular-material framework and specifically utilize its <md-select/> component. I am interested in styling its icon: https://i.stack.imgur.com/g4pu1.png In the past, we would modify its css by targeting the class .md-select-icon, ...

Unable to make a div grow within a Popper component in a React.js application

I'm facing a challenge with implementing a CSS feature and need some assistance. https://i.stack.imgur.com/KXpGd.png Upon clicking the "See link options" button, the content loads but spills out of the popper. My goal is to have the popper expand in ...

The server sends a response with a MIME type that is not for JavaScript, it is empty

I am trying to integrate an angular application with cordova. Upon running "cordova run android" and inspecting it in Chrome, the console displays the following message: "Failed to load module script: The server responded with a non-JavaScript MIME t ...

"When using Webpack and Sass, the background image specified with background: url() is processed correctly. However, when using webpack-dev-server, the image is

Currently, I am utilizing Webpack 2 in conjunction with webpack-dev-server and Sass loader. Here is my current configuration: { test: /\.scss/, loaders: [ "style", { loader: "css", query: { modules: false, sourceMap: true } }, ...

Whenever I try to import a directory that contains modules, Webpack encounters an error

I am currently in the process of developing a small npm library to streamline API interaction. Here is an overview of my folder structure... dist/ index.js src/ index.js endpoints/ endpoint1.js package.json webpack.config.js Inside my src/index ...

Having trouble with the filtering feature in Material UI Datagrid

I'm currently using Material UI Data Grid to display a table on my website. The grid has an additional filter for each column, but when I click on the filter, it hides behind my Bootstrap Modal. Is there a way to bring it to the front? https://i.stac ...

Issue with using async await in map function: async function may not complete before moving on to the next item in the

Currently, I have an array that needs to be mapped. Inside the mapping function, there is an asynchronous function being called, which conducts an asynchronous request and returns a promise using request-promise. My intention was for the first item in the ...

Interceptors in axios do not trigger when making requests through a PHP proxy

I am currently working on a React app that will be interacting with services hosted on a remote server. During development on my local machine using the react-scripts server at localhost:3000, I disable CORS in the browser and have no issues with axios f ...

Saving real-time information to MongoDB with Node.js

What is the best way to use JSON.stringify and send it to my mongoDB Database? For instance: import express from 'express'; let data_record = JSON.stringify({**any content**}) This snippet of code will automatically fetch data every 60 second ...

HTMLElement addition assignment failing due to whitespace issues

My current challenge involves adding letters to a HTMLElement one by one, but I'm noticing that whitespace disappears in the process. Here's an example: let s = "f o o b a r"; let e = document.createElement('span'); for (let i ...

Error 504 occurs on Express.js due to a timeout issue while a timer is active

Encountering a "504 Gateway Timeout" error on my Express.js application when a JavaScript timer is set to run every 20 seconds. Here is the code for my Express.js listener and the timer: const express = require('express') const app = express() ...

What is the best way to conceal the keyboard in a Flutter dropdown menu?

I'm currently working on a project using Flutter and experiencing issues with the keyboard opening when a user clicks on the DropDownMenu. I am looking for a solution to prevent the keyboard from popping up when the user interacts with the dropdown li ...

The issue lies with Express Mongoose failing to store the data

Encountering some issues when trying to save an object created in Express nodejs using mongoose. Despite receiving a confirmation that the object is saved, it cannot be located even after attempting to access it through the server. Express route for savi ...

Unable to adjust image opacity using jQuery

I am attempting to change the opacity of an image based on a boolean flag. The image should have reduced opacity when the var pauseDisabled = true, and return to full opacity when pauseDisabled = false. To demonstrate this, I have created a fiddle below. ...

The parsing of source maps fails due to issues with the .htaccess file

After analyzing the web page, I found that the .htaccess file contains the following code: RewriteEngine On RewriteBase / Options -MultiViews DirectorySlash Off # skip POST requests RewriteCond %{REQUEST_METHOD} POST RewriteRule ^ - [L] RewriteCond %{R ...

Utilize MaterialUI's stepper component to jazz up your design with

Is there a way to customize the color of a material ui Stepper? By default, the material UI stepper's icons use the primary color for both "active" and "completed" steps. class HorizontalLinearStepper extends React.Component { state = { activeS ...

AngularJS bidirectional binding with numerous select choices

I am faced with a unique challenge - I have a list of non-exclusive fields that users want to see presented in a select box allowing multiple selections, rather than individual checkboxes bound to Boolean values in the model. While I know how to create t ...

Is it necessary for the scope to be separated?

In the document object model (DOM), I have two straightforward directives that are responsible for creating similar elements. Both directives have an isolated scope. Each directive has an ng-click attribute that calls a method to display a message. One d ...