Skip to content

Instantly share code, notes, and snippets.

@sergeysova
Last active January 19, 2016 20:18
Show Gist options
  • Save sergeysova/ee5c964fa301208010d7 to your computer and use it in GitHub Desktop.
Save sergeysova/ee5c964fa301208010d7 to your computer and use it in GitHub Desktop.
function getPath(el) {
var path = el.nodeName;
if (el.parentNode && el.parentNode.nodeName !== 'BODY') {
path = getPath(el.parentNode) + ' ' + path;
}
return path.toLowerCase();
}
document.addEventListener('click', function(event){
var path = getPath(event.target);
console.log(path);
}, true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment