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

75
Visualizações
I need resolve this menu dropdown issue

Here is my code:

HTML:

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
 <meta charset="utf-8">
  <title></title>
  <link rel="stylesheet" href="C:\Users\gyld2\Documents\dropdown menu\dropdown.css">
</head>
<body>
  <script type="text/javascript" src="C:\Users\gyld2\Documents\dropdown menu\dropdown.js"></script>
  <button id="btn">Click Here</button>
  <ul id="list">
    <li>item</li>
    <li>item</li>
    <li>item</li>
    <li>item</li>
  </ul>
</body>
</html>

JS:

const button = document.getElementById("btn");

const list = document.getElementById("list");

list.style.display = "none";

button.addEventListener("click",(event)=> {
  if (list.style.display == "none") {

    list.style.display = "block";

    else {

          list.style.display = "none";
    }
  }
})

how my menu looks like

and i want it to be something like this:

how it is when it's closed.

how it is when it's opened.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Typo Error

if (list.style.display == "none") {
   list.style.display = "block";
 }
else {
  list.style.display = "none";
}

const button = document.getElementById("btn");

const list = document.getElementById("list");

list.style.display = "none";

button.addEventListener("click",(event)=> {
  if (list.style.display == "none") {
      list.style.display = "block";
    }
    else {
      list.style.display = "none";
    }
})
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
 <meta charset="utf-8">
  <title></title>
  
</head>
<body>
  
  <button id="btn">Click Here</button>
  <ul id="list">
    <li>item</li>
    <li>item</li>
    <li>item</li>
    <li>item</li>
  </ul>
</body>
</html>

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