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

211
Visualizações
How to display dropdown menu from an icon

I have a hidden menu and I'm trying to display it in JS after clicking an icon. I want to be able to open and close the menu off of the notification bell.

Here is the HTML, CSS and JS I tried:

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 Respostas
Responde à pergunta

0

you have a typo in code

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