Using JS to highlight the specified keyword in the article content is like this .. now we have these keywords: beauty, life, and shopping. When these keywords appear in articles, we will highlight them .. the article generates static pages, and these keywords can be updated at any time, so I want to use JS to implement it... I don't know how to implement this function? Here for help
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
Multiple keywords
Using JS to highlight the specified keyword in the article content is like this .. now we have these keywords: beauty, life, and shopping. When these keywords appear in articles, we will highlight them .. the article generates static pages, and these keywords can be updated at any time, so I want to use JS to implement it... I don't know how to implement this function? Here for help
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
Copy codeThe Code is as follows:
$ (JScript 5.5 or later)
$ & Specifies the part of stringObj that matches the entire pattern. (JScript 5.5 or later)
$ 'Specifies the stringObj section before matching by $. (JScript 5.5 or later)
$ 'Specifies the stringObj part after matching by $. (JScript 5.5 or later)
$ N indicates the nth child matching captured. Here, n is the first digit in decimal format from 1 to 9. (JScript 5.5 or later)
$ Nn: the nn sub-match captured by nn. nn is a two-digit decimal number from 01 to 99. (JScript 5.5 or later)
G, global pattern matching
I, case-insensitive matching
Multiple keywords. A good method. I also use this method.
<Html> <body> use JavaScript to highlight the keyword specified in the document content .. now we have these keywords: beauty, life, and shopping. When these keywords appear in articles, we will highlight them .. the article generates static pages, and these keywords can be updated at any time, so I want to use JS to implement it... I don't know how to implement this function? For more information, see <table id = "ttxt"> .. now we have these keywords: beauty, life, and shopping. When these keywords appear in articles, we will highlight them .. the article generates static pages, and these keywords can be updated at any time, so I want to use JS to implement it... I don't know how to implement this function? Here for help </table> </body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
Why do we have to restrict ourselves to HTML replacement? Isn't it more convenient to start with text objects?
<Pre> using JS to highlight the keyword specified in the article content is like this .. now we have these keywords: beauty, life, and shopping. When these keywords appear in articles, we will highlight them .. the article generates static pages, and these keywords can be updated at any time, so I want to use JS to implement it... I don't know how to implement this function? Here for help </pre>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
<Pre> yes .. now we have these keywords: beauty, life, and shopping. When these keywords appear in articles, we will highlight them .. the article generates static pages, and these keywords can be updated at any time, so I want to use JS to implement it... I don't know how to implement this function? Here for help <pre>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]