Skip to content

Instantly share code, notes, and snippets.

@evaldobarbosa
Created September 17, 2019 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evaldobarbosa/f525f42f6e05365a821e162855dd3df6 to your computer and use it in GitHub Desktop.
Save evaldobarbosa/f525f42f6e05365a821e162855dd3df6 to your computer and use it in GitHub Desktop.
window.addEventListener('load', function() {
document.querySelectorAll('.btn-group .btn')
.forEach(item => {
item.addEventListener('click', function(e) {
e.target.parentNode.childNodes.forEach(function(node) {
if (node.firstChild !== null) {
node.firstChild.removeAttribute('checked')
}
if (node.classList !== undefined) {
node.classList.remove('active')
}
})
e.target.classList.add('active')
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment