My Script
var cwidth = document.getElementById('contentarea').clientWidth;
var elements = document.getElementsByClassName("shadow");
for(var i=0; i<elements.length; i++) {
elements[i].style.width = cwidth+"px";
var anc = elements[i].getElementsByTagName("a"); // not working in IE 7 & 8
anc[0].style.width = cwidth+"px";
}
This script working well in all browsers except IE 7 & 8
Any one please help me
getElementsByClassNameisn’t supported in IE<9.In IE8 you can use:
But keep in mind that it’s not a live collection like the one you get with
getElementsByClassName. And if you want to look for elements with multiple classes, you’ll have to dodocument.querySelectorAll(".first.second");.As for IE7, you have to rely on something else, like a weel known framework (like jQuery or just Sizzle), or a function like this:
This isn’t a live collection either, moreover you won’t be able to search for elements with multiple classes. That is, unless they are ordered like you want in their
classNameproperty, but you can’t rely on that. You’ll have to do something more complicated, I’ll leave it to you when you’ll get more experienced in Javascript.