Skip to content
Branch: master
Go to file

Latest commit


Failed to load latest commit information.
Latest commit message
Commit time

jQuery Highlight

Find some text in the DOM. The difference between this and other Plugins is that it looks for text in multiple nodes. It uses DOMRanges and therefor it doesn't works in IE < 10.

Add to improve the speed.


You can find some examples here.

Basic usage:

$('body').highlight("Search Query");

This will search for the text "Search Query" in the whole document will only highlight the first hit.

Multiple occurrences:

To highlight all occurrences of the text you have to pass an option object like this:

$('body').highlight("Search Query", {onlyFirst : false});

The 'options'

The default options are:

	onlyFirst : true,
	fuzzy : true,
	ignorePrevFounds : true,
	classCountPrefix : '_',
	className : 'jQuery_Highlight',
	ignoredChars : /\r|\n|\s/,
	ignoredTags : /(script|style|iframe|object|embed)/i,
	callback : function () {}

onlyFirst : true if only the first occurrence should be highlighted.
fuzzy : Switch to enable/disable fuzzy logic. Default is true.
ignorePrevFounds : don't search in previously found text.
classCountPrefix : the highlighted text will be wrapped in span tags with a class like className + ' ' + classCountPrefix + Upcounting Number
className : the className of all highlighted text
ignoredChars : RegEx to test if the Char is ignored in the comparison.
ignoredTags : RegEx, tags that are ignored while iterating the DOM.
callback : a callback for each highlighted text, to add Custome data and do some fancy stuff with highlighted text.

In Action

I used it in combination with my node.js API wrapper nodequote to create a bookmarklet to highlight the 'topquote' of an article. Just try it


A little plugin to search for text in the DOM



No releases published
You can’t perform that action at this time.