168
rated 0 times
[
172]
[
4]
/ answers: 1 / hits: 18687
/ 13 Years ago, thu, july 21, 2011, 12:00:00
I know that if we want to find a group of elements, getElementsByTagName is the method for us and it returns a NodeList. but if we are looking for tag name with body , then why we need to add [0] after the (body) element? There is only one body tag in an HTML document.
var body = document.getElementsByTagName(body)[0];
body.className = unreadable;
why we cant write this code without index[0] like this
var body = document.getElementsByTagName(body);
body.className = unreadable;
If i write this code the class unreadable will not be added with body tag ...why?
More From » html