I want to replace a word [ONLY 1 TIME], in my case 'Ronaldo', with hyperlink on EVERY post on my site. So, I used the following code.
document.body.innerHTML = document.body.innerHTML.replace('Ronaldo', '<a href="www.ronaldo.com">Ronaldo</a>');
That really worked well until i noticed the issue.
It's even replacing the word 'Ronaldo' on post-title
when i want it to replace the word in post-body
only.
Here's a glimpse of my code so you can have a better understanding.
https://codepen.io/vkdatta27/pen/rNMGbmj [UPDATED]
It would be very helpful if someone says a way to fix this issue. I'm tagging jquery and ajax because they too know javascript.
NOTE: UNTIL NOW, WE DIDN'T USE ANY CLASSES, IDS, TAGS LIKE POST-BODY
P
EXCEPT POST-TITLE
FOR FORMATTING PURPOSE
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…