Is it possible to select only part of a string using jquery? For example I have a text
Metuentes igitur idem latrones Lycaoniam magna parte campestrem&l
If you know the element in which to search:
var string = "Lycaoniam";
var e = $("elementSelector"); // put here your selector
e.html(e.html().replace(new RegExp(search, "gi"), ""+search+""));
for more elements, simply loop through them and do the replacing. To make a toggable styling, I'd use a custom class:
e.html(e.html().replace(new RegExp(search, "gi"), ""+search+""));
and remove it with:
$(".highlight").contents().unwrap();
.contents().unwrap() does the trick of stripping not only the class (which must be styled accordingly) but also the tag.