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

73
Views
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 answers
Answer question

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 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!