Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

199
Vistas
How can I remove an <h2> dynamically?

Maybe this is a basic question, but I should stress I know very little about these things. Essentially, in my page I have something like:

<h2>Some text there</h2>
<h2>Other text there</h2>

And I would like to make it simply into:

Some text there
Other text here

I mean, essentially, I want to remove the H2 surrounding the text. It'd be super easy to just delete it, but unfortunately I only have indirect access to the code. Is there any way to remove this dynamically using Javascript?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can loop through all h2 elements and replace each element with a text node of the element's textContent (with document.createTextNode):

document.querySelectorAll('h2').forEach(e => e.parentNode.replaceChild(document.createTextNode(e.textContent), e))
<h2>Some text there</h2>
<br/>
<h2>Other text there</h2>

about 4 years ago · Juan Pablo Isaza Denunciar

0

Eventually, I found this solution, which was perfect for my case, but I'd also want to thank everyone who posted here!

document.addEventListener('DOMContentLoaded', e => {
    const h2s = document.querySelectorAll("h2")

    h2s[0].outerHTML = h2s[0].innerHTML
    h2s[1].outerHTML = h2s[1].innerHTML
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda