I have the following table. What do i need to use in JavaScript to read the number from the below cell named "number"?
<table>
<tr>
<td id="number">56656.87</td>
</tr>
</table>
I have tried the following however it does not work.
document.getElementById('number');
Using raw JavaScript:
var text = document.getElementById('number').innerText;
Using jQuery:
var text = $('#number').text();
The innerHTML
property holds the contents of that cell. If you got [object Object] on your last attempt you're almost there. This is how you do it:
var n = document.getElementById('number').innerHTML;
Make sure there's no other number id on that page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With