Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

highlight each occurrence of text

const term; // search query we want to highlight in results 
const results; // search results

results.replace(new RegExp(term, "gi"), (match) => `<mark>${match}</mark>`);
Source by bitsofco.de #
 
PREVIOUS NEXT
Tagged: #highlight #occurrence #text
ADD COMMENT
Topic
Name
5+3 =