我遇到标记问题。我输入一个带有句点的单词,如果它在那里它可以匹配(例如Filters.
)但是当它通过标记功能时,它不起作用。这是代码:
function Search () {
var Notes = document.getElementById("NoteHolder").innerHTML;
var i = document.getElementById("Bar").value;
var inputReOne = $.trim(i);
var inp = inputReOne.replace(".", "\.")
if ($.trim(inp) !== '') {
var InpComp = inp.toUpperCase();
var Ind = tags.indexOf(InpComp);
if (Ind === -1) {
var inpReg = new RegExp(inp, "im");
var WordCheck = Notes.match(inpReg);
alert(WordCheck)
if(WordCheck !== null) {
tags.push(InpComp);
var SearchReq = new RegExp("\\b(" + inp + ")\\b", "gim");
var after = Notes.replace(SearchReq, "<mark class=" + ColorOptionReady + ">$1</mark>");
document.getElementById("NoteHolder").innerHTML = after;
}
WordCheck
匹配Filters.
但是当它通过函数的其余部分时,它不会添加<mark class=ColorOptionReady (A variable)>Filters.</mark>
它只留下没有标记标记。有什么建议吗?