Here is a snippet that I found in the internet that adds a class to specific substring of a paragraph.
Problem is that when the paragraph contains elements that are not words – like an element of type , it eliminates this element completely from the outcome.
Can someone modify it to preserve the element as well?
Thx
jQuery(document).ready( function ($) {
var oldString = ‘some words’,
newString = ‘some words‘,
newText = $( “p:contains(‘some words’)” ).text().replace(RegExp(oldString,”gi”),newString);
$( “p:contains(‘some words’)” ).html(newText);
}); // jQuery(document).ready( function ($) {