标签:com http class blog style div img code java javascript log
getByclass传入两个参数,oParent是父集,sClass是要传入class名称
1 function getByClass(oParent,sClass){ 2 var aChild = oParent.getElementsByTagName("*"), 3 result = []; 4 for(var i =0;i<aChild.length;i++){ 5 if(aChild[i].className.match(new RegExp("(\\s|^)" + sClass+ "(\\s|$)"))){ //判断是否有该class 6 result.push(aChild[i]); 7 }; 8 }; 9 return result; 10 };
通过正则写一个较为完美的getByClass函数,布布扣,bubuko.com
标签:com http class blog style div img code java javascript log
原文地址:http://www.cnblogs.com/fyima/p/3698239.html