Home  >  Article  >  Web Front-end  >  JavaScript implements keyword highlighting function_Basic knowledge

JavaScript implements keyword highlighting function_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 16:31:351785browse

The highlighting function mainly refers to highlighting the specified text in the specified area on the page, that is, background coloring. Generally, this function is often used on the search results page.

The following is a solution for everyone, implemented with javascript.

First introduce the following javascript method in :

Copy code The code is as follows:


The fHl method above is used to achieve highlighting, and the meaning of the parameters is written in the comments.

Then call the fHl method at the end of the page to highlight the text in the specified area, for example:

Copy code The code is as follows:


How about it, it’s very simple~

Statement:
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