jQuery plugin: WordFilter

Current Version:1.0
Compressed filesize:    1.5K
License: Apache 2.0
Tested in: Firefox 2.0, 3.0, IE 6, 7
Dependencies: jQuery 1.2.x (tested with 1.2.6).

The WordFilter plug-in adds two functions to jQuery. These are a filter by word function and an "auto Search" function.

The filterWord function is similar to the standard jQuery filter function, however instead of jQuery expressions, the selected elements' text are filtered by an array of words. There are options available for using "or" and "not" logic with this test as well as specify "prefix", "whole" (word), and "contains" match types.

For example, to only display paragraphs containing the word "show", you can use:

      $('p').hide().show(['show'],{matchType: whole}).show();
See the wordFilter jsDocs for details on options, etc.

The autoSearch function is an easy way to add a filter page display by words that a user inputs into a text field. This occurs "close" to real time as the user types. "Close" means that for performance reasons, the filter is not applied until the user stops typing.

For example, if the page has a Text input field named "#searchTextBox" and a list of elements identified with a common class like ".products", the autoSearch plug-in can be used by:

As the user enters text into the searchTextBox, the .product elements will be filtered to display only the elements that contain the words that start with the words entered.

Quick Start

For those who want to jump right in and skip ready documents...