Last active
May 15, 2017 07:24
-
-
Save thatisuday/39b31a3b804d65f657675a8d2116ede1 to your computer and use it in GitHub Desktop.
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
jQuery(document).click(function(event){ | |
event.stopPropagation(); | |
var elem = event.target; | |
function traverseUp(el){ | |
var result = el.tagName.toLowerCase() + ':eq(' + $(el).index() + ')', | |
pare = $(el).parent()[0]; | |
if (pare.tagName !== undefined && pare.tagName !== 'BODY'){ | |
result = [traverseUp(pare), result].join('>'); | |
} | |
return result; | |
}; | |
console.log('jQuery("body>' + traverseUp(elem) + '");'); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment