Skip to content

Instantly share code, notes, and snippets.

@d4rkr00t
Created May 6, 2015 04:58
Show Gist options
  • Save d4rkr00t/a833ec69508b52ccd46f to your computer and use it in GitHub Desktop.
Save d4rkr00t/a833ec69508b52ccd46f to your computer and use it in GitHub Desktop.
Shows length of selected elems text
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