jQuery Plugin To Highlight Matched Terms Within Document - Text Highlight

File Size: 7.23 KB
Views Total: 645
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
jQuery Plugin To Highlight Matched Terms Within Document - Text Highlight

Just another jQuery text highlighter plugin which allows to highlight specified text strings with case sensitive and Regular Expressions support.

Basic usage:

1. Load the Text Highlight jQuery plugin after jQuery library and we're ready to go.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="jquery.text.highlight.js"></script>

2. Call the function on the container and specify the words, text or Regular Expressions you want to highlight.

$('.container').textHighlight(['Lorem', 'Aliquam']);

3. By default, the plugin will wrap the matched strings in the mark element, so that you can style the highlighted text in the CSS:

mark { ... }

4. Add a specific class to be added to the mark element.

$('.container').textHighlight(['Lorem', 'Aliquam'],{
  'class': 'custom-class'
});

5. Enable the case sensitive functionality.

$('.container').textHighlight(['Lorem', 'Aliquam'],{
  'caseSensitive': true
});

6. Modify the default wrapping element.

$('.container').textHighlight(['Lorem', 'Aliquam'],{
  'element': 'mark'
});

7. Specify a subset of elements that should be ignored.

$('.container').textHighlight(['Lorem', 'Aliquam'],{
  'ignore': undefined
});

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