I need to create hyperlinks for certain words in my posts. I found a code snippet that does this:
document.body.innerHTML = document.body.innerHTML.replace('Ronaldo', '<a href="www.ronaldo.com">Ronaldo</a>');
While this code works as intended, it also replaces the word Ronaldo
in titles and headings. I only want it to modify text within the post-body
and not affect post-title
or <h>
tags.
I'm mentioning jquery and ajax because they are relevant to JavaScript too.