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

108
Views
inserting new tags with class names in Javascript innerText?

I made a forEach case for text loop, and this moment, I;m facing a problem that I cannot put span tag in return result of innerText.

data.forEach(item => {
  const dataTitle = document.createElement('p');
  dataTitle.innerText = data.title + '<span class="p-90">' + data.subTitle + '</span>'
  viewContainer.appendChild(dataTitle);
});

this is my code, but the < span class =".... is exposed to the site in raw. how can I fix it?

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

0

Try this. use innerHTML instead of innerText and replace data.title with item.title. same for data.subTitle.

data.forEach((item) => {
      const dataTitle = document.createElement("p");
      dataTitle.innerHTML =
        item.title + '<span class="p-90">' + item.subTitle + "</span>";
        viewContainer.appendChild(dataTitle);
    });
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!