Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

115
Vistas
Make a dropdown to show with click instead of hover

I am trying to add a function onclick for my dropdown menu, so instead of showing when I hover, I want it to show when I click on it, do you know what can I do?

My dropdown is on the grid icon next to "Images"

This is my repo so you can view my code: https://github.com/Diefonro/HTML-CSS

You can also see the page displayed right now at: https://diefonro.github.io/HTML-CSS

Thank you

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

you have to implement the below function and call it on the onclick event. and as @Tom suggested you need to get rid of the below part also from the style sheet

.dd-cont:hover .drop-d {
   display: block;
}

this is how we catch specific element which has particular class and we can change styles of the elements like below

function clickDD() {
    const dropdown = document.querySelector('.drop-d');
  dropdown.style.display = dropdown.style.display === 'block' ? 'none' : 'block';
}

here is a working example(jsFiddle) from your code

ps I did not included any assets to the fiddle

about 4 years ago · Juan Pablo Isaza Denunciar

0

To handle the click event, you can take a look at EventListener or onclick attribute.

The dropdown is shown on hover because of this CSS rule :

.dd-cont:hover .drop-d {
   display: block;
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda