Free Download

Site Search

 

Top Download

Wednesday, September 26, 2007

highlight: JavaScript text higlighting jQuery plugin




jQuery Plugin: Text Highlight

Text higlighting is part of
DynaCloud – where tags/keywords are automatically highlighted once they’re clicked – so I took that code and made it a stand-alone JavaScript text highlighting jQuery plugin.
Demo
Each of the links will highlight the corresponding word.
highlight
javascript
Remove highlights.
Usage
Add highlight
Download
jquery.highlight-1.js (2 KB) and add it to your page along with a jQuery version.
Style the highlight class
Create an entry in your style sheet for the highlight class..highlight { background-color: yellow }
Highlight terms
Call the $.highlight function with the start node and the text to highlight. Note that at this time the text must be upper-cased. To highlight all occurrances of “BLA” (case insensitive) in all li elements, use the following code:$('li').each(function() { $.highlight(this, 'BLA'); }));
Remove highlighting
The highlight can be removed from any element with the removeHighlight function. In this example, all highlights under the element with the ID highlight-plugin are removed.$('#highlight-plugin').removeHighlight();

No comments: