DEV Community

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

supportic profile image

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.

aniket_chauhan profile image
Aniket Chauhan Author

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