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

101
Views
Way to replace all divs (ignore their class and IDs) - extension

I need a simple extension that deletes all divs (with any ID or class). Extension should be running in WP text editor, so I'm using

textEditor.value = textEditor.value

I guess it should use .replaceAll, but I'm not sure how to word expression to delete all divs and ignore their ID and class. Both ID and class should be deleted also.

Example:

<div id="example1" class="example2">Text</div>

Should be just:

<p>Text<p>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

This will search for all div tags in the current DOM. And replace it with the span tag.

var divs = document.querySelectorAll("div");
var l = divs.length
for(var i = 0; i < l; i++){
  var text = divs[i].innerText;
  var p = document.createElement("p");
  p.innerText = text;
  divs[i].replaceWith(p);
}
about 4 years ago · Juan Pablo Isaza Report

0

var elem = document.getElementById("myDiv");
var html = elem.innerHTML;
var parent = elem.parentNode;
var textEl = document.createElement('p')
textEl.innerHTML = html
parent.appendChild(textEl)
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!