Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!