Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have to <a href="https://developer.mozilla.org/en/JavaScript/Reference/Statements/for" rel="nofollow">iterate</a> over all <code>tr</code> elements (which is a <a href="https://developer.mozilla.org/en/DOM/NodeList" rel="nofollow"><code>NodeList</code> <em><sup>[MDN]</sup></em></a>, returned from <a href="https://developer.mozilla.org/en/DOM/element.getElementsByTagName" rel="nofollow"><code>getElementsByTagName</code> <em><sup>[MDN]</sup></em></a>):</p> <pre><code>for(var i = 0, l = tableRows.length; i &lt; l; i++) { var row = tableRows[i]; //... } </code></pre> <p>Inside the loop you can get all <code>td</code>s of one row again with <code>getElementsByTagName</code> or using the <a href="https://developer.mozilla.org/en/DOM/HTMLTableRowElement" rel="nofollow"><code>.cells</code> <em><sup>[MDN]</sup></em></a> property. You can then decide to either iterate over them as well or to access the specific cells explicitly, such as <code>cells[1]</code> to access the second cell (second column) in that row.</p> <p>If the cells contain simple text or you don't have any event handlers bound to their descendants, you can simply use <a href="https://developer.mozilla.org/en/DOM/element.innerHTML" rel="nofollow"><code>innerHTML</code> <em><sup>[MDN]</sup></em></a> to change the element's text content.</p> <p>Otherwise you have to <a href="https://developer.mozilla.org/en/DOM%3adocument.createTextNode" rel="nofollow">create a new text node</a> and <a href="https://developer.mozilla.org/En/DOM/Node.appendChild" rel="nofollow">append it</a> to the cell (that might be the best option in any case).</p> <hr> <p>The <a href="https://developer.mozilla.org/en-US/" rel="nofollow">Mozilla Developer Network</a> is a great source for all kinds of information, including the DOM and JavaScript.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload