首页 > 代码库 > addClass,removeClass

addClass,removeClass

function addClass(obj,aclass){    if(obj.className == ‘‘){        obj.className = aclass;    }else{        var arr = obj.className.split( );        var _index = arrIndexOf(arr,aclass);        if(_index == -1){            obj.className +=  +aclass;        }    }   }function removeClass(obj,aclass){    if(obj.className!=‘‘){        var arr = obj.className.split( );         var _index = arrIndexOf(arr,aclass);        if(_index != -1){            arr.splice(_index,1);            obj.className = arr.join( );        }    }}function arrIndexOf(arr,v){    for(var i=0;i<arr.length;i++){        if(arr[i] == v){            return i;        }    }    return -1;};

 

addClass,removeClass