posts - 14,  comments - 0,  views - 6708
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

 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 };
复制代码

 

 

posted on   Durian`Yi  阅读(495)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示