I\'ve been trying to make a simple search inside a static HTML page using JQuery. I have to mention that this is just my first time working with JQuery.
I\'m trying
Do something like this
$("p:contains('"+searchedText+"')").each( function( i, element ) {
var content = $(element).text();
content = content.replace( searchedText, '' + searchedText + '' );
element.html( content );
});
.search-found {
text-decoration: underline;
}
p.s. this will work only if each of the "elements" has plain text only content otherwise it would remove children nodes
EDIT: removed the extra ')' in the each callback