Skip to content

Instantly share code, notes, and snippets.

@SigurdMW
Created June 2, 2017 07:00
Show Gist options
  • Save SigurdMW/fc4500b8184311308541604f3f021c34 to your computer and use it in GitHub Desktop.
Save SigurdMW/fc4500b8184311308541604f3f021c34 to your computer and use it in GitHub Desktop.
// classlist helper for better browser compat
var hasClass = function (el, className) {
if (el.classList) {
return el.classList.contains(className);
} else {
return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
}
}
// helper for setting multiple attributes to same element
function setAttributes(el, attrs) {
for (var key in attrs) {
el.setAttribute(key, attrs[key]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment