Last active
May 11, 2017 07:46
-
-
Save thatisuday/d5f0b8bde9c591753972737151f93bf8 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 + ':nth-child(' + ($(el).index() + 1) + ')', | |
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