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

203
Views
Cómo mostrar el menú desplegable desde un icono

Tengo un menú oculto y estoy tratando de mostrarlo en JS después de hacer clic en un icono. Quiero poder abrir y cerrar el menú fuera de la campana de notificación.

Aquí está el HTML, CSS y JS que probé:

 const notificationMenu = document.getElementById("notification-menu"); const notificationBell = document.getElementById("noti-bell"); notificationBell.addEventListener("click", function() { if (notificationMenu.style.display = 'none') { notificationMenu.style.display = 'block' } else { notificationMenu.style.display = 'none' } });
 .notification-menu { display: flex; flex-direction: column; justify-content: space-around; text-align: center; position: absolute; height: 250px; width: 350px; left: 58vw; bottom: 66vh; background-color: white; border: solid 2px #686de0; z-index: 1; font-size: 14px; display: none; }
 <span class="noti-bell" id="noti-bell"><i class="fa-solid fa-bell"></i></span> <div id="notification-menu" class="notification-menu"> <span class="noti-menu-header">Notifications<a href="#" class="read notifications">Mark all as read</a></span> <ul> <li><a href="#"><span>You Have 1 New Task!</span></a></li> <li><a href="#"><span>You Have 1 New Reminder!</span></a></li> <li><a href="#"><span>You Have 1 New Note!</span></a></li> <li><a href="#">You Have 2 New Events!</a></li> <a href="#"><span class="clear-notifications">Clear Notifications</span></a> </ul> </div>

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

tienes un error tipográfico en el código

 if (notificationMenu.style.display === 'none') {
about 4 years ago · Santiago Trujillo 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!