1 function GetElementsByName(tag, name) { 2 var elem = document.getElementsByTagName(tag); 3 var arr = []; 4 var index = 0; 5 var l = elem.length; 6 for(var i = 0; i < l; i++) { 7 var att = elem[i].getAttribute("name"); 8 if(att == name) { 9 arr[index++] = elem[i]; 10 } 11 } 12 return arr; 13 }
时间: 2024-11-09 17:59:00