Created
May 6, 2015 04:58
-
-
Save d4rkr00t/a833ec69508b52ccd46f to your computer and use it in GitHub Desktop.
Shows length of selected elems text
This file contains 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.body.addEventListener('click', function chooseElem (e) { | |
e.preventDefault(); | |
e.stopPropagation(); | |
var text = e.target.innerText; | |
console.groupCollapsed ('Text'); | |
console.log(text); | |
console.groupEnd('Text'); | |
console.info('Total length: ', e.target.innerText.length); | |
console.info('Total length without spaces: ', e.target.innerText.replace(/\s/g, '').length); | |
document.body.removeEventListener('click', chooseElem); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment