1. className 相关方法
function hasClass(obj, classname) {
reg = new RegExp("\\b" + classname + "\\b");
//reg=/((\s)*(\w)*)*tra_box((\s)*(\w)*)*/;
return reg.test(obj.className);
//return obj.className.match(reg);
}
function addClass(obj, classname) {
if (hasClass(obj, classname)) {
return;
} else {
obj.className += " " + classname;
}
}
function removeClass(obj, classname) {
if (hasClass(obj, classname)) {
obj.className = obj.className.replace(classname, "");
} else {
return;
}
}