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

129
Vistas
Cannot access textContent of HTML el but can console log it

so i am trying to manipulate with table on this website.

my script i insert in the chrome/firefox console on the website:

let skins = [
"button" //simplified 
];

skins.forEach((skin)=>{

document.querySelector("tbody").childNodes.forEach((k,i)=>{
if(i>0){ // starts with 1 because i==0 is #text
    
    console.log(k.childNodes[1].textContent); // this works in chrome,firefox
    
    let h = k.childNodes[1].textContent; 
    if(h == "shades") console.log("yes"); // this part doesnt work - error 
}
})

});

when i console.log it, it does work, and show all the <tr> on position 1. But when i try to do some code with if statement, the error message shows up,

 Cannot read properties of undefined (reading 'textContent')
at <anonymous>:11:30
at NodeList.forEach (<anonymous>)
at <anonymous>:8:44
at Array.forEach (<anonymous>)
at <anonymous>:6:7
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You are missing {}

if(h == "shades") console.log("yes")

do instead:

if (h == 'shades') {
 console.log("yes");
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

Sorry, i didnt carefully set the boundaries, thats why i get an error. There was another #text and the results also needed .trim() to remove extra whitespace.

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