| All we know that getElementsByTagName() a DOM function in Javascript is used to get all the child elements for an particular element.Consider this following scenario I have an table with the id as “parentTable”, which has many child tables in it. so my structure will be like this, |
<table id='parentTable'> <tr> <td> <table id='childTable1'> <tr> <td>My First Article</td> </tr> </table> </td> </tr> </table> |
| If i’m going to use parentTable.getElementByTagName(”tr”), i’ll be getting the count as 2, Which is what i’m not looking for. I wanted to get the count as 1.Guys please give some alternative suggesstion. |
Tags: FireFox, Javascript













You may want to use
document.getElementById()to get a single element with given id. The method document.getElementByName() by default returns all the matching elements from the DOM. More on getElementByName: http://www.w3schools.com/htmldom/met_doc_getelementsbyname.asp