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

175
Vistas
Plain javascript selector for html element without html markup

I'm working on a small project where I'd to read how many times a monster has been killed by a specific player. I'm able to create most of the selectors (monster name, player name) when using the document.querySelector or document.querySelectorAll. But when I want to retrieve the amount of kills I'm stuck. Also Googling for selectors of plain text, or text without HTML markup. Unfortunately I have no results.

To give you an idea how it looks like I will give a small example. The HTML looks exactly like this, but then you have 6 player names list and for each player the amount of kills for this specific monster.

<table>
<tr>
<td><b>Name of the monster</b></td>
<td><b><a href="#">Name of the player</a></b>"Amount of kills"<br></td>
</tr>
</table>

So I want to get the selector of the text that mentions the Amount of kills. I will then convert this string to a number.

My idea is to create a tracker to see what players are actually hunting. For example player X kills 500 dragons, then I want my script to display this.

Thanks in advance! :)

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

0

Here's one way:

const cell = document.querySelector('table tr td:last-child');

console.log([...cell.childNodes].filter(n=>n.nodeType===3).pop().nodeValue);
<table>
<tr>
<td><b>Name of the monster</b></td>
<td><b><a href="#">Name of the player</a></b>"Amount of kills"<br></td>
</tr>
</table>

It finds the table cell you need, and reads all childNodes (this includes textNodes (nodeType is 3 then)), filters for all textNodes and pops the last one, reading its value.

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