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

158
Views
Can you style ordered list numbers in javascript?

I have something that selects a line number in a list, and I have line numbers made by using an ordered list. When I have a line number selected, I want the line number indicator for that specific line to change a color. How do I do this?

I know that you can style it in CSS by doing li::marker, but how would I change the individual list item markers in javascript?

https://replit.com/@KittyCraft0/3D-modeling-software-10#ObjSettings/SelPoint.js:67:29

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

0

You can add a class to list items you want to highlight.

document.querySelector('ol').children[1].classList.add('highlight');
li.highlight::marker {
  color: red;
}
<ol>
  <li>item</li>
  <li>item</li>
  <li>item</li>
  <li>item</li>
</ol>

The :nth-child() pseudo-class can be used if the items are known in advance.

li:nth-child(2)::marker {
  color: red;
}
<ol>
  <li>item</li>
  <li>item</li>
  <li>item</li>
  <li>item</li>
</ol>

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!