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

119
Vistas
Assign a CSS class to a selected element WebComponent

I'm working on a school project based on WebComponents where we have to draw a calendar (I just hardcoded it) and we have to pass a value (the day of the month) on the HTML tag, just like this:

<calendar-sheet day=1></calendar-sheet>

I want to apply a specific CSS class (.active) to the same day that is passed. For example, if I write day=10, I want to apply that class to the tenth day of the month. I have added a specific ID for every day in order to identify the days, like this:

<li id="1">1</li>
<li id="2">2</li>
<li id="3">3</li>
<li id="4">4</li>
<li id="5">5</li>

I tried to do the following, but I am stuck here:

selectDay(){
   this.renderRoot.getElementById(this.day).classList.add('active')
}
about 4 years ago · Juan Pablo Isaza
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