How to find particular dom element inside codemirror source code string

I am creating the live html editing. I can access the dom element on the html side using mouse event. I want to trace the element in the codemirror html string.

I think you should parse that HTML code and search in the tree node for the node that matches what you need (e.g., when you click on it is should be selected in the CodeMirror editor).

This website will be helpful insha’Allah: