javascript - Highlight selected word -


i need implement both highlight , un-highlight selected text in textarea. please me implement one. tried following code highlight , un-highlight

$('.highlight').click(function(){     var selection= window.getselection().getrangeat(0);     var selectedtext = selection.extractcontents();      var span= document.createelement("span");     span.style.backgroundcolor = "yellow";     span.appendchild(selectedtext);     selection.insertnode(span); });  $('.remove_highlight').click(function(){     var selection= window.getselection().getrangeat(0);     var selectedtext = selection.extractcontents();     var span= document.createelement("span");     span.style.backgroundcolor = "white";     span.appendchild(selectedtext);     selection.insertnode(span); }); 

here, .highlight , .remove_highlight separate buttons, in advance


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -