题解 | #字体高亮#
字体高亮
https://www.nowcoder.com/practice/1b7437b538af4689b1509db2068abe55
btn.onclick = () => { // 补全代码 let mytext = text.innerText; let myvalue = new RegExp(search.value,'g'); if(search.value!==''){ mytext = mytext.replace(myvalue, `<b style="background:yellow;">${search.value}</b>`); } text.innerHTML = mytext; };