What Is Wrong With This Getelementsbyclassname Call In Javascript?
I am trying to access the width of a div to put in a cookie. This is the div:
It is the only div with this class name. It is not
Solution 1:
Solution 2:
document.getElementsByClassName("tab_panel")
returns a collection of nodes, the first of which is referred to by document.getElementsByClassName("tab_panel")[0]
.
If the node you are searching does not have an inline style="width:' assignment, an empty string is returned from document.getElementsByClassName("tab_panel")[0].style.width
.
Solution 3:
Missing quotes:
document.getElementsByClassName('tab_panel').....
You should iterate over all elements like this:
var elms = document.getElementsByClassName('tab_panel');
for(var i = 0 ; i < elms.length; i++)
{
alert(elms[i].style.width);
}
Solution 4:
Try saying:
document.getElementsByClassName("tab_panel")
Post a Comment for "What Is Wrong With This Getelementsbyclassname Call In Javascript?"