Last active
March 12, 2017 16:31
-
-
Save pravj/783359e46b0e05b507c1331a51622a8e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('DOMContentLoaded', function() { | |
document.querySelectorAll('label')[0].classList.add('button-press'); | |
document.addEventListener('click', function(e) { | |
var e = e || window.event, | |
target = e.target || e.srcElement, | |
text = target.textContent || target.innerText; | |
if (target.tagName.toLowerCase() == 'label') { | |
var labels = document.querySelectorAll("label"); | |
[].forEach.call(labels, function(el) { | |
el.classList.remove("button-press"); | |
}); | |
target.classList.add("button-press"); | |
console.log('text', text); | |
console.log('target', target); | |
console.log('tagname', target.tagName.toLowerCase()); | |
} | |
}, false); | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment