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

84
Views
Retrieve value from img tag

I want to get the favoriteid value.

<td class="favoriteRow" style="">

  <img src="/images/starGold.png" loading="lazy" favoriteid="bitcoin">

</td>

This is what I tried but got back undefined.

console.log(this.childNodes[0]['favoriteid'])

The console.log(this) outputs:

<td class="favoriteRow" style="">

  <img src="/images/starGold.png" loading="lazy" favoriteid="bitcoin">

</td>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Something like this?

See docs!

const img = document.querySelector("img[favoriteid]");
console.log( img.getAttribute("favoriteid") )
<td class="favoriteRow" style="">
  <img src="/images/starGold.png" loading="lazy" favoriteid="bitcoin">
</td>

or

document.querySelector(".favoriteRow img").getAttribute("favoriteid")

console.log(document.querySelector(".favoriteRow img").getAttribute("favoriteid"));
<table>
  <td class="favoriteRow" style="">
    <img src="/images/starGold.png" loading="lazy" favoriteid="bitcoin">
  </td>
</table>

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!