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

234
Vistas
How to target an element using multiple class names with Javascript?

I am working in Wordpress and I was able to target an element to change some of the CSS with this exact code:

body.admin-bar .mobmenu{
top:140px;
}

I need to also target this exact element with Javascript to change it's CSS properties after the user has scrolled down the page to reset it back to: top:0px

How would I target this using Javascript since it's multiple class names? I can't assign it an ID

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

0

Assuming this is the only element with this classname.

You can use the document query selector

const myElement = document.querySelector("body.admin-bar.mobmenu")

Should do the trick

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