函数封装写法

function addclass(obj,str){

var _str=obj.getAttribute("class");//获取原有的class

var ok=_str+" "+str;//加上需要使用的class

obj.setAttribute("class",ok)//设置class

}

function removeclass(obj,str){

var old_css=obj.getAttribute("class");

var so=old_css.replace(str," ")

var reg=/\s+/g

var ne=so.replace(reg," ")

obj.setAttribute("class",ne)

}