function hasClass(ele,cls) {
return ele.className .match(new RegExp('(\s|^)' cls '(\s|$)'));
}
function addClass(ele,cls) {
if (!this.hasClass(ele,cls)) ele.className = " " cls;
}
function RemoveClass(ele,cls) {
if (hasClass(ele,cls)) {
var reg = new RegExp('(\s|^)' cls ' (\s|$)');
ele.className=ele.className.replace(reg,' ');
}
}
//함수 호출
addClass(document.getElementById("test"), "test");
removeClass(document.getElementById("test"), "test")
if(hasClass(document.getElementById("test"), "test")){//do Something};