0
Can I use Javascript to change the td content in a table?
I have tr (with an id="one") and 3 td's, with text "Over", "Under" and "Between", respectively. After selecting the tr element using document.getElementById("one"), how do I change say "Between" to "Through" ?
6 Réponses
+ 1
// Assuming element "Between" is the third td element.
document.querySelectorAll("#one td")[2].innerText = "Through";
+ 1
Calvin, thank you! Why does trip.childnodes[2].innertext = not work?
+ 1
childNodes
0
I started with var trips = document.getElementById("one") then var arr = trips.childNodes then arr[2].innerHTML = "Through"; ** Wanted to understand why this approach is incorrect**
0
Please note that whitespace and text is considered as nodes and comments are also considered as nodes.