Skip to content

Instantly share code, notes, and snippets.

@lgedeon
Created May 7, 2014 14:23
Show Gist options
  • Save lgedeon/71f798057deec21e5695 to your computer and use it in GitHub Desktop.
Save lgedeon/71f798057deec21e5695 to your computer and use it in GitHub Desktop.
toggle class by id on div without any other classes (maximum compatibility limited use case)
function namespace_divname_toggle(){
this.className=("active"==this.className.substr(0, 6))?"":"active";
}
document.querySelector('#divname').addEventListener('click', namespace_divname_toggle )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment