Created
March 18, 2018 05:10
-
-
Save eramdam/0d1f42e9f4a6077b3f87e6c5f9b2d274 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
const getSelector = el => { | |
let sel = []; | |
let currEl = el; | |
while (!!currEl) { | |
sel = [`${currEl.tagName.toLowerCase()}.${currEl.className.trim().replace(/\s+/g, '.')}`, ; | |
currEl = currEl.parentElement; | |
} | |
return sel.join(' > '); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment