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

158
Vistas
Activating CSS through a HTML button press

I was wondering if you can activate some CSS through an HTML button press or scrolling to a certain point. It's preferred if it's through JS.

about 4 years ago · Santiago Gelvez
2 Respuestas
Responde la pregunta

0

You can use a wrapper class:

const button = document.querySelector("button")
button.addEventListener("click", () => {
  document.body.classList.add("red")
})
.red {
  color: red;
}
<h1>Stackoverflow is nice!</h1>
<p>Great website!</p>
<button>Change CSS</button>

  • Create a button which listens for a user action.
  • When the button is clicked add a class to the body element.
  • Use this class to apply different css rules.

You can build a dark theme with that for example.

about 4 years ago · Santiago Gelvez Denunciar

0

As previously said by @Lain, it is indeed possible. something like someElement.classList.add() or someElement.classlist.toggle() MDN Web API

about 4 years ago · Santiago Gelvez 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