• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

195
Views
Cómo eliminar Resaltar (<marca>) de un párrafo usando Javascript

Tengo HTML donde algunos párrafos contienen elementos <mark> . Esto hace que se resalte el texto dentro del elemento <mark> . Esencialmente, quiero eliminar el resaltado eliminando el elemento <mark> pero manteniendo el contenido del texto.

¿Cuál es la mejor manera de hacer esto?

Aquí hay un párrafo de ejemplo:

Ejemplo con texto resaltado

Quiero eliminar el texto resaltado. El HTML contiene <span> y otros elementos y algunos elementos <mark> que no quiero eliminar. Los que quiero eliminar tienen una clase de .show-mark. Sé cómo encontrar solo los elementos <mark> que quiero eliminar, pero no sé cómo eliminarlos.

Aquí está el HTML para el párrafo de ejemplo:

 <p id="p85" class="cmiTranPara note-style-bookmark note-style-bookmark-start note-style-bookmark-end"> <i class="playmark play icon"></i> <i class="timing large circular red clock icon"></i> <span class="pnum has-annotation" data-aid="1574791210024">(p85)&nbsp;</span> Miracle-mindedness is still a stage of perception just short of <mark class="show-mark">master</mark>y. For <mark class="show-mark">master</mark>y comes when you know that you are literally and deliberately creating. And there is nothing miraculous about it. You will decree a thing and it shall be so! </p>

Gracias por tu ayuda.

almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Prueba algo como esto

 targets = document.querySelectorAll("mark"); for (let target of targets) { target.outerHTML=target.innerHTML; }

y ver si funciona.

almost 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error