Skip to content

Instantly share code, notes, and snippets.

@VoloshchenkoAl
Created January 19, 2017 07:29
Show Gist options
  • Save VoloshchenkoAl/c159ebdf849d5ce3d9592736d9f917aa to your computer and use it in GitHub Desktop.
Save VoloshchenkoAl/c159ebdf849d5ce3d9592736d9f917aa to your computer and use it in GitHub Desktop.
_workWithDOM:{
_empty: function( parent ) {
while (parent.firstChild) {
parent.removeChild(parent.firstChild);
}
},
_removeClass: function( el, className ) {
if( el.classList ) {
el.classList.remove( className );
} else {
var classes = el.className.split(" ");
classes.splice(classes.indexOf(className), 1);
el.className = classes.join(' ');
}
},
_addClass: function( el, className ) {
if( el.classList ) {
el.classList.add( className );
} else {
var classes = el.className.split(" ");
el.className = classes.concat( className ).join(' ');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment