Home > Web Front-end > JS Tutorial > body text

JavaScript implements keyword highlighting function_Basic knowledge

WBOY
Release: 2016-05-16 16:31:35
Original
1784 people have browsed it

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~

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