function hasClass(ele,cls) { return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)')); } if(hasClass(document.getElementById("test"), "test")){
maybe this will help you :-)
Using jQuery would be simpler and less code, but never mind!
source share