javascript traversing table

Posted by user234194 on Stack Overflow See other posts from Stack Overflow or by user234194
Published on 2010-04-19T15:43:30Z Indexed on 2010/04/19 15:53 UTC
Read the original article Hit count: 227

Filed under:
|

If I have a certain code, How do I traverse or get to the button(i.e type == INPUT) in JavaScript.

<td> <div>
    <script></script>
    <script></script>
    <script></script>

       <input type="button"....../>
</div></td> 

I tried doing:

var cell = row.cells[0];
if (cell) {
var btn1 = cell.firstChild;
alert(btn.tagName.toUpperCase());

this resulted "DIV", and

var cell = row.cells[0];
if (cell) {
var btn = btn1.firstChild;
alert(btn.tagName.toUpperCase());

this resulted "SCRIPT"

But doing same (i.e firstChild ) , I could not succeed.

Any help is appreciated. Thanks

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about dom