I have written a basic script to search the DOM for strings and replace. But in it's current state, it will affect URLs of links too.
For example replacing "example" with "my example" would break the following example;
<a href="http://my example.com/my example">My Example</a>
How could I stop this for happening, so the result would in fact return like this?
<a href="http://example.com/example">My Example</a>
Is there a way to automatically account for CAPs or would this require a separate search string?
Here is my code;
$(document).ready(function(){
$("body").children().each(function() {
$(this).html($(this).html().replace(/example/g,"my example"));
})
});
There will be approximately 80 words to find/replace, from a perfromace point of view, is there a better method of handling this? Short of separate pages per languages of course.