Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

206
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda