getElementsByClassName
is unfortunately not reliable cross-browser. It's currently supported by the most recent versions of Firefox, Opera, Safari, and Chrome, but not at all in Internet Explorer or Konqueror, according to Quirksmode.
If you want to use it cross-browser, you'll have to have to provide your own implementation for those browsers that don't support it, like in PPK's blog:
function getElementsByClassName(node,classname) {
if (node.getElementsByClassName)
return node.getElementsByClassName(classname);
else {
// your custom function
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…