JS-utilities

added minimized version
This commit is contained in:
2017-11-15 15:12:51 +01:00
parent a8cfd05769
commit f7c78cf322
7 changed files with 37 additions and 93 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ function hasClass( el, className ) {
return el.classList.contains( className );
} else {
/**/
return !! el.className.match( new RegExp( "(\\s|^)" + className + "(\\s|$)" ) );
return ! ! el.className.match( new RegExp( "(\\s|^)" + className + "(\\s|$)" ) );
}
}
+1
View File
@@ -0,0 +1 @@
function hasClass(b,a){if(b.classList){return b.classList.contains(a)}else{return !!b.className.match(new RegExp("(\\s|^)"+a+"(\\s|$)"))}}function addClass(b,a){if(b.classList){b.classList.add(a)}else{if(!hasClass(b,a)){b.className+=" "+a}}}function removeClass(c,b){if(c.classList){c.classList.remove(b)}else{if(hasClass(c,b)){var a=new RegExp("(\\s|^)"+b+"(\\s|$)");c.className=c.className.replace(a," ")}}};