Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!