<script> <br>function HighLight(nWord){ <br><br>if(nWord!=''){ <br><br>var キーワード = document.body.createTextRange(); <br>while(keyword.findText(nWord)){ <br><br>keyword.pasteHTML("<span style='color:red;'>"keyword.text "</span>"); <br><br>keyword.moveStart('character',1); <br><br>} <br><br>} <br><br>function highword(nWord){ <br><br>var array = nWord.split(","); <br><br>for(var i=0;i<array.length><br>HighLight(array[ i] ); <br><br>} <br></script>
liujinzhong liujinzhong
js の強調表示方法 2:
2.
var reg = new RegExp("(" key.replace(/,/,"|") ")","g"); 🎜>ele.innerHTML = ele.innerHTML.replace(reg,"$1");
}
window.onload = function( )
{
highLight(document.getElementsByTagName("p")[0],"li,jin");
//-->
>