<script>
    var FungetElementsByClassName = function(str,root,tag){
         if(root){
             root = typeof root == "string" ? document.getElementById(root) : root;
         } else {
             root = document.body;
         }
         tag = tag || "*";
         var els = root.getElementsByTagName(tag),arr = [];
         for(var i=0,n=els.length;i<n;i++){
             for(var j=0,k=els[i].className.split(" "),l=k.length;j<l;j++){
                 if(k[j] == str){
                 arr.push(els[i]);
                 break; 
             }
         }
     }
     return arr;
    } 
    var addClass = function(node,str){
         if(!new RegExp("(^|\\s+)"+str).test(node.className)){
         node.className = node.className + " " + str;
     } 
    }
    var removeClass = function(node,str){
     node.className = node.className.replace(new RegExp("(^|\\s+)"+str),"");
    } 
    var d = document.getElementsByClassName('pop')[0];
    addClass(d,'cur');
    // removeClass(d,'cur')
    FungetElementsByClassName('pop').height = "300px";
    </script>

 

posted on 2016-06-29 11:20  小海豚Dolphins  阅读(323)  评论(0编辑  收藏  举报