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

92
Views
I Read using QuerySelectall.. how to write in innerhtml of these read tags?

I have degrees in Celsius switched them to Fahrenheit and cannot write them back to page.. picked them up with this statement

temp = document.querySelectorAll(".mylist span");
        x=[]
        for (let i = 0; i < temp.length; i++) {
            temp[i].style.backgroundColor = "red";
            x[i] = Number(temp[i].innerHTML);

Cannot write them back same way... Does not work

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

0

You need to set the innerHTML/textContent of the element with the new value.

const spans = document.querySelectorAll('#mylist span');

function CToF(v) {
  return v * 9/5 + 32;
}

setTimeout(() => {
  spans.forEach(span => {
    const { textContent } = span;
    span.classList.add('red');
    span.textContent = CToF(textContent);
  });
}, 2000);
.red { color: red; }
<div id="mylist">
  <span>10</span>
  <span>40</span>
  <span>90</span>
</div>

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!