Inspector feature for web element and its javascript code

I’m working on project that allow web element created by js code (ex: by clicked button) , can trace the source that created its.
More detail, when i clicked on an element that created by js code, devtool window will move on debugger window or script tag (in html file) and highlight code created that element.
I got some issue at starting (like details document about source code, or where to start, so on). So can i any advice from you?