Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

305
Visualizações
How to remove Highlight (<mark>) from a paragraph using Javascript

I have HTML where some paragraphs contain <mark> elements. This causes the text within the <mark> element to be highlighted. Essentially, I want to remove the highlight by removing the <mark> element but keeping the textContent.

What's the best way to do this?

Here's an example paragraph:

Example with highlighted text

I want to remove the highlighted text. The HTML contains <span> and other elements and some <mark> elements that I don't want removed. The ones I want removed have a class of .show-mark. I know how to find just the <mark> elements that I want to remove but I don't know how to remove them.

Here's the HTML for the example paragraph:

<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>

Thanks for your help.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try something like this

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

and see if it works.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda