What is the best way to highlight a specific substring in a div element in an event? By highlight, I mean apply some CSS style, like yellow background or something.
Basically I need a simple JS client side function of the form:
function (element, start, end) {
// element is the element to manipulate. a div or span will do
// start and end are the start and end positions within the text of that
// element where highlighting should be.
// do the stuff
}
Only one highlight will be active.
See Question&Answers more detail:os