Home > Web Front-end > JS Tutorial > Two ways to implement javascript highlighting effect_javascript skills

Two ways to implement javascript highlighting effect_javascript skills

WBOY
Release: 2016-05-16 19:01:02
Original
1120 people have browsed it
js highlighting method one:
Copy code The code is as follows:

<script> <br>function HighLight(nWord){ <br><br>if(nWord!=''){ <br><br>var keyword = document.body.createTextRange(); <br><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>} <br><br>function highword(nWord){ <br><br>var array = nWord.split(","); <br><br>for(var i=0;i<array.length;i ){ <br><br>HighLight(array[i] ); <br><br>} <br><br>} <BR></script>




liujinzhong liujinzhong liuzhong






js highlighting method two:

2.
Copy code The code is as follows:

< html>

Test Page

< ;/head>


liujinzhong liujinzhong liuzhong




Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template