-
-
Save yaru22/6bd0b0f9e4466aa9c661 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// requires mootools selectors | |
var path = function path(element) { | |
if(element.get('id')) { | |
return '#' + element.get('id'); | |
} | |
if(element == document.body) { | |
return 'body'; | |
} | |
var prev_equal_siblings_length = element.getAllPrevious(element.get('tag')).length; | |
var part = element.get('tag') + ':nth-of-type(' + (prev_equal_siblings_length + 1) + ')'; | |
return path(element.getParent()) + ' > ' + part; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment