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

252
Vistas
How can I use JavaScript to delete a class?

I am at an academy where they are asking me to put in a 800px image and then use the <img>: class = "small" tag to make it shrink and then they tell me this:

The goal of this part of the project is that you will use JavaScript to either remove this "small" class (and thus the image will grow) or reposition it (thus it will become small again) when the user clicks.

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

0

You need to use the classList property of the HTML element.

// Select the element
const myElement = document.querySelector("#my-element");

// Add a class
myElement.classList.add("class-to-add");

// Remove a class
myElement.classList.remove("class-to-remove");

Here is the corresponding documentation: https://developer.mozilla.org/docs/Web/API/Element/classList

about 4 years ago · Juan Pablo Isaza Denunciar

0

// garp the image by it's className
const myImage = document.querySelector('.myImage')

// add event listener to respond click event
myImage.addEventListener('click', () => {
  // it will toggle on and off whene ever used clicks it 
  myImage.classList.toggle('small')
})
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