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

131
Views
Remove certain character from string and return into an array

I've got a string that has html tag like this:

var list = "<ul><li><p>example 1st</p></li><li><p>example 2nd</p></li></ul>"

how can I remove every character of The u, p, li tags

so i can get return result in array like this :

['example 1st','example 2nd']
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can create a div and then find all the text using innerText using querySelectorAll and array#map.

const list = "<ul><li><p>example 1st</p></li><li><p>example 2nd</p></li></ul>";
const div = document.createElement('div');
div.innerHTML = list;
const text = [...div.querySelectorAll('ul li p')].map(element => element.innerText);
console.log(text);

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!