Learning Javascript at the moment, so please bear with me. I created a table in my connected.html and I am trying to obtain the element between the <td>
tags in my event-page.js. I used document.getElementByID("tokens")
, however I get null, I want to get 12. I think I have to do more with document.getElementByID("tokens")
I used .innerText
and .innerHTML
but those didn't work. Any help would be appreciated! Sorry for such a simple problem.
*Note: The function in event-page.js is called when a button is clicked by the user.
connected.html
<html>
<head>
</head>
<body>
<table>
<tr>
<td colspan="4" class="info">Tokens</td>
</tr>
<tr>
<td id="tokens">12</td>
</tr>
</table>
</body>
</html>
event-page.js
chrome.extension.onMessage.addListener(function(request, sender, sendResponse){
if (request.action.split(':')[0] === 'got-it'){
yt_name = (request.action.split(':')[1])
console.log(yt_name)
let table = document.getElementById("tokens")
console.log(table)
}
})