DEV Community

Discussion on: Generate a CSS selector path of a DOM element.

Collapse
supportic profile image
Supportic

Open Devtools -> select element in DOM -> right click: copy -> copy selector. Voila. :)
But yeah if you want dynamically create CSS selectors maybe not onclick but for something else, the functions might come in handy.

Collapse
aniket_chauhan profile image
Aniket Chauhan Author

Yeah, true. But for demonstrate purpose I used click event 😅