Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
What you're missing here, is that when you create a variable via document.getElementsByTagName("tr"), what you're actually doing is creating an array of items. Note that Element s is plural. To get the id of each tr, you must loop through the array:
Code:
var test = document.getElementsByTagName("tr");
for(var i= 0; i<test.length; i++) {
alert(test[i].id);
}
Be sure to either place this as an onload function, or else place the script down at the bottom so it runs after all the HTML is finished loading.
|