Skip to content

Instantly share code, notes, and snippets.

@remibreton
Last active October 31, 2023 18:30
Show Gist options
  • Save remibreton/6598908 to your computer and use it in GitHub Desktop.
Save remibreton/6598908 to your computer and use it in GitHub Desktop.
function addClass(element, cls){
if(typeof element.classList !== "undefined"){
element.classList.add(cls);
} else {
element.className += element.className.indexOf(cls) == -1 ? cls : ' ' + cls;
}
return element;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment