Highlight the text Using Jquery/javascript

Below is the snippet that you can use to highlight the text on the page. var text = “Search Text”; if (window.find && window.getSelection) { document.designMode = “on”; var sel = window.getSelection(); sel.collapse(document.body, 0); while (window.find(text)) { console.log(text) document.execCommand(“HiliteColor”, false, “yellow”); sel.collapseToEnd(); } document.designMode = “off”; }