I need to write a script that will allow me to check the value of any link in a table cell. The desired result would be something like this:
Expand|Select|Wrap|Line Numbers
- row[0].cell[2].innerHTML
The following script may be of use as a starting point:
Expand|Select|Wrap|Line Numbers
- <table id="table">
- <tr>
- <td><a href="#">hello1</a></td>
- <td><a href="#">hello2</a></td>
- </tr>
- <tr>
- <td><a href="#">hello3</a></td>
- <td><a href="#">hello4</a></td>
- </tr>
- </table>
- <script type="text/javascript">
- window.onload = function() {
- var table = document.getElementById('table');
- var rows = table.getElementsByTagName('tr');
- for (i=0; i < rows.length; i++) {
- var cells = rows[0].getElementsByTagName('td');
- for (j=0; j < cells.length; j++) {
- alert(cells[1].getElementsByTagName('a').innerHTML); // Desired result is hello2 but returns undefined
- }
- }
- }
- </script>
akadeco