I have the following words:
<a class="logo-home" href="#" title="abc xyz">abc xyz</a>
<img src="#" title="abc xyz" alt="abc xyz"/>
<h1>abc xyz</h1>
<p>blabla... abc xyz ... blabla</p>
I want to change string "abc xyz" to <span style="white-space:nowrap;">abc xyz</span>
To do that, I use this code:
document.body.innerHTML = document.body.innerHTML.replace(/abc xyz/g, "<span style="white-space:nowrap;">abc xyz</span>");
But I don't want it change text in title attribute or atl attribute of element. All I want is just change text content in element. I try some regex but the problem still remain. Is Anyone have some advice for me? Many thanks.