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

219
Views
How can i add style to the element in javascript?

I have this piece of code inside my javascript, I want to select the element by the class name and then be able to style it, how can I do that?

const versesHtml = `              
                ${verses.map( (v, i) => `<li class="text">${v.text_uthmani}</li> <li class="ayahNumber">{${i+1}}</li>`).join(' ')}
               
                
               
            `;

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

using the DOM selector and then css properties, like this:

const styling = document.querySelector('.text');
styling.style.backgroundColor = 'yellow';
styling.style.color = 'red';
about 4 years ago · Juan Pablo Isaza Report

0

var elements = document.getElementsByClassName('ayahNumber'); // get all elements
    for(var i = 0; i < elements.length; i++){
        elements[i].style.backgroundColor = "black";
    }
about 4 years ago · Juan Pablo Isaza Report
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!