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

Transform a text string into JSON format using Javascript

I need help converting a text string to JSON format using JavaScript. The text string is as follows: workingtable;AB8C;book_id;7541; I want to convert it into JSON format like this: {"workingtable":"AB8C","book_id":"7541"} Is there a specific JSON funct ...

Utilizing numerous copies of a single plugin

I recently integrated a plugin called flip-carousel.js into my website and here is an example of how it looks on the site. Check out the sample implementation Now, I encountered an issue when trying to use multiple instances of the same plugin. When init ...

Determine the variance between the final two items in an array composed of objects

I am trying to figure out how to calculate the difference in total income between the last two months based on their IDs. It seems that {income[1]?.total} always gives me a constant value of 900. Any suggestions on how I can accurately calculate the tota ...

An element in defaultProps deemed as nonexistent

As I dive into routes and routing practice, I've encountered some challenges that have me stumped. The issue seems to be in the render method in App.js. The concept is simple - I'm working on a getDogFunc function that should help me locate a s ...

utilizing async/await without the need for babel-polyfill

Here is the code I am working with: @action async login(payload){ try { this.loginLoading = true const data = await request('/admin/login', { method: 'post', data: payload }) this.logined = ...

The web element cannot be located, but it becomes visible when manually inspected

I'm facing an issue with accessing this menu in selenium as the web element doesn't show up in the inspector until I do it manually. <a id="cke_3275" class="cke_menubutton cke_menubutton__table cke_menubutton_off cke_menubutton_ ...

Issue with Jquery .scroll method not triggering display:none functionality

Styling Using CSS #acc-close-all, #to-top { position: relative; left: 951px; width: 29px; height: 42px; margin-bottom: 2px; display:none; } #acc-close-all a, #to-top a { position: absolute; float: right; display: block ...

What is the best way to configure my Express API endpoint so that it can generate customized responses based on the parameters in the URL?

Currently working on a react-admin project where I need to establish a connection with an express server using a data provider. Despite my efforts, I have been unable to implement sorting and pagination functionality. It seems like modifications are requi ...

A guide on implementing AJAX redirection in MVC

I currently have a button that, when clicked, takes input values and redirects to another page in JavaScript using the following code window.location = "Action Param1=value1&Param2=Value2". However, I am looking to avoid using query strings for this me ...

Can jQuery help me identify which <input type='image> was clicked within a form containing several submit images?

Consider this hypothetical scenario: <form> <input type="text" name="some_name" value="val" id="some_name"> <input type="image" value="action" alt="Add To Cart" name="add" src="/images/submit.gif"> <input type="image" value="act ...

Attempting to retrieve key-value pairs from a nested JSON array

I am attempting to extract values along with their corresponding key names from a nested JSON array resData =[ { _index: 'web', _type: 'event', _id: 'web+0+93', _score: null, _source: { 'os-nam ...

Updating React Native using setState is not possible

In my React Native application, there is a function that deletes an item: delete(index){ this.setState({deletedIndex:index, cachedCart:this.state.Cart, Cart: this.state.Cart.splice(index,1) }, function(){ console.log(th ...

Tips for generating a <span> element using the img alt tag and inserting it following the <img> element

I have a set of images with 'alt' tags and I would like to extract the 'alt' tag for each img and create a <span> + alt tag + </span> line after each image. I am unsure of how to achieve this using jQuery. The desired outpu ...

How to trigger a component programmatically in Angular 6

Whenever I hover over an <li> tag, I want to trigger a function that will execute a detailed component. findId(id:number){ console.log(id) } While this function is executing, it should send the id to the following component: export class ...

Where do the props in React come from?

In my quest to learn React. I perused w3school's guide, but alas, the specific case I seek was not found. Even Google failed me in this pursuit, leading me here to pose my question. Behold, the code in question: <FooComponent foo="bar"> {( ...

Achieve this effect by making sure that when a user scrolls on their browser, 50% of the content is entered into view and the remaining 50%

Is there a way to achieve this effect? Specifically, when the user scrolls in the browser, 50% of the content is displayed at the top and the other 50% is shown at the bottom. ...

Challenges with Input Nesting

Why is the word "undefined" appearing on top of my text? function printName() { document.write('My name is John Doe.'); } function printAge() { printName(); document.write('I am 47 years old.'); } document.querySelector(&ap ...

Eliminate the need for pressing the "tab" key on my website

I'm currently working on a horizontal web page layout and I'm looking for a way to disable the "tab" button functionality on my page. The issue arises because I have a contact form with textboxes located in the last div, and when users navigate u ...

How to bring in images from a local source in a React.js file

I've been looking into relative paths and absolute paths, but I'm having trouble importing local images correctly. My main objective is to create a React slideshow using these images. Why does it keep trying to find the images in the "components" ...

Is it possible to showcase a dropdown list within a constantly changing table?

I have a table code snippet that I need help with <fieldset class="tabular"><legend><%= l(:redmine_taskjuggler) %></legend> <%= labelled_fields_for(@issue) do |f| %> <div id="taskjuggler" class="attributes"> <div cl ...