Text index to Html index

Viewed 176

I want to ask if there is a quick way I to find the index of a word in an html element from its plain text index? lets say I have the following:

innerHTML = <span>Hello</span><br><span>World!</span>
innerText = Hello \n World!

suppose I want to find the index of word "World" in innerHTML where all I know is its begin and end index in innerText.

Edit

Actually I am trying to replace some wrong words in am html text but keeping their styles and structure, for example if a word is in an span element I want to change it without affecting anything else

0 Answers
Related