Hi, i have the following code:
function getArticleContent() {
var toPromote = 'example';
var toReplace = '<a href="/tags/'+toPromote+'">'+toPromote+'</a>';
var content = $(".a-entry").text();
if (content.search(toPromote) > -1)
{
$('.a-entry').html($('.a-entry').html().replace(new RegExp(toPromote, "g"), toReplace) );
}
else
{
//
}
}
$(document).ready(function() {
getArticleContent();
});
The code works fine, but if an image, or link has an title or alt attribute equal with the text that i want to replace the html it's broken, because the script put's the link in the alt, or title tag.
Best regards