I have a problem with some code. I put the input and the text in the paragraph is highlighted using <mark>
. But when I add a period to highlight all periods, the code freaks out and gives me the actual html code and has random glare. So I tried to add a replacement to change the periods. Now he will not worry, but with will not highlight anything. Here is my code to try to replace the period with the html character number ( .
):
var i = document.getElementById("Bar").value; var inpu = $.trim(i); var inp = inpu.replace(".", "."); var SearchReq = new RegExp("(\\b" + inp + "\\b)", "gim"); var Notes = document.getElementById("NoteHolder").innerHTML; var after = Notes.replace(SearchReq, "<mark class=" + ColorOptionReady + ">$1</mark>"); document.getElementById("NoteHolder").innerHTML = after;
What is the problem with the code? (I tried to remove the "\ b" in the regex, but that didn't fix it.)
source share