Highlight Any Strings Using Regex - jquery.highlight.js

File Size: 3.53 KB
Views Total: 1950
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Highlight Any Strings Using Regex - jquery.highlight.js

Just another text highlighting jQuery plugin that enables you to highlight any strings within a specific container element using Regular expressions.

How to use it:

1. Download and place the main JavaScript file jquery.highlight.js after jQuery.

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" 
<script src="./jquery.highlight.js"></script>

2. Highlight numbers using Regex.

<table border="0" class="table table-bordered">
$("table").trigger("search.highlight", /[0-9]+/g);

3. Highlight characters in the HTML table.

$("table").trigger("search.highlight", "Jan");

4. The plugin automatically add the highlihgted strings around span tags with the class of .hightlight. So that you can style the highlihgted strings in the CSS.

.highlight { 
  font-weight: bold;

5. Clear the highlight effect.




This awesome jQuery plugin is developed by page7. For more Advanced Usages, please check the demo page or visit the official website.