Quiero obtener el valor de favoriteid .
<td class="favoriteRow" style=""> <img src="/images/starGold.png" loading="lazy" favoriteid="bitcoin"> </td> Esto es lo que intenté pero regresé undefined .
console.log(this.childNodes[0]['favoriteid'])Los resultados de console.log(this):
<td class="favoriteRow" style=""> <img src="/images/starGold.png" loading="lazy" favoriteid="bitcoin"> </td>¿Algo como esto?
Ver documentos !
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>o
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>