Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
I need help to open menu on click on a href link in html?

i have tried from last few days but unable to open megamenu on click of ahref link, after done some code checkup, i have found some hint in css, in that if i make visibility value to visible then megamenu shows otherwise not, i want that menu to be open only on click right now it's opening on hover event and below code to be executed only onclick of ahref tag

.menu-subs, .menu-column-4 
{
    visibility: hidden!important;   
}

below is ref. screenshot for menu

menu-screen

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You will need to include some JavaScript to your code. Here are some examples on how to use it.

 <button onclick="myFunction()">Click me</button> 
 <element onclick="myScript"> 
 object.onclick = function(){myScript}; 
 object.addEventListener("click", myScript);

I would also recommend using technologies like bootsrap or angular to deal with menus and navigation bars. They make life easier and is good to know how to use them.

about 4 years ago · Juan Pablo Isaza Report

0

If you want to make it so that when you click something them menu is visible, you could use the onclick function in the href and toggle the visibility of the menu using css display: non or block.

HTML: you are creating a div with the css properties of that class and assigning it an id. you are also creating a link that will call the javascript function when clicked

<div class="menu-subs" id="menu">
// the menu
</div>

<h1 onclick="openMenu()">Open menu</h1>

CSS: the class which is not displayed currently

.menu-subs, .menu-column-4 
{
    display: none; 
}

Javascript:

function openMneu(){
    //get the menu element in the html
    elem = document.getElementById("menu");

   // set the styling of the menu to visible
   elem.style.display = "block"; //or inline block depending on your other css
}

when openmenu is called by the clicking of the heading open link. You could also use element.addeventlistender, bit that would be a bit harder, so i suggest you try this. This should work, lmk if it does

(this is my second stackoverflow answer :|)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!