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

186
Vistas
Trying to pull H3 text using JS

I am trying to create a Google tag manager JS variable to pull the article name when someone clicks on it.

enter image description here

I need to pick up just the title (in red) but not " Home Sellers "

document.getElementsByClassName("blog-listing-post__summary blog-listing-post__summary--big")[0].querySelector("H3").innerText

returns:'HOME SELLERS\nWhich Home Appliances are Included with a Sold Property?'

How can I skip "home sellers" and pull value just under?

Thank you!

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

0

Try using the split() and slice() methods. This will return an array that you can reference.

let x = 'HOME SELLERS\nWhich Home Appliances are Included with a Sold Property?';

let y = x.split('\n').slice(1);

console.log(y);
console.log(y[0]);

about 4 years ago · Juan Pablo Isaza Denunciar

0

const h3 = document.querySelectorAll('h3').at(-1).innerText
about 4 years ago · Juan Pablo Isaza Denunciar

0

If you want all and only the top level text, you just need to filter the H3's childNodes to get only text nodes and then join all the text together. The solution below should work in most cases.

const myHeadline = document.getElementsByTagName('h3')[0];
const myHeadlineTopLevelText = [...myHeadline.childNodes].filter(node=> node.nodeType === 3).map(node=>node.textContent).join("").trim();
console.log(myHeadlineTopLevelText);
<h3>
<span>sub text</span>
Main text
</h3>

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