上传文件至 app/static/js
parent
d8e4fbbb2d
commit
cfd85a5035
|
@ -43,12 +43,12 @@ function highLight() {
|
|||
// 删除所有的mark标签,防止标签发生嵌套
|
||||
articleContent = articleContent.replace(/<(mark)[^>]*>/gi, "");
|
||||
articleContent = articleContent.replace(/<(\/mark)[^>]*>/gi, "");
|
||||
// 将文章中所有出现该单词word的地方改为:"<span class='highlighted'>" + word + "</span>"。
|
||||
// 将文章中所有出现该单词word的地方改为:"<mark>" + word + "<mark>"。
|
||||
for (let word of totalSet) {
|
||||
articleContent = articleContent.replace(new RegExp("\\b" + word + "\\b", "g"), "<span class='highlighted'>" + word + "</span>");
|
||||
articleContent = articleContent.replace(new RegExp("\\b" + word + "\\b", "g"), "<mark>" + word + "</mark>");
|
||||
}
|
||||
document.getElementById("article").innerHTML = articleContent;
|
||||
|
||||
$('mark').css('padding', 0);
|
||||
}
|
||||
|
||||
function cancelHighlighting() {
|
||||
|
|
Loading…
Reference in New Issue