自定义getElementsByClassName( ) 方法

function getElementsByClassName (className) {
   var all = document.all ? document.all : document.getElementsByTagName( ' *' );
    var elements = new Array();
    for ( var e = 0; e < all.length; e ++ ) {
      if (all[e].className == className) {
       elements[elements.length] = all[e];
        break ;
      }
    }
   return elements; 
}

相关推荐