jQuery(document).ready(function (e) {
var columnsToIndex = [1, 2, 3]; // first column is 1
initLiveFilter(columnsToIndex);
});
// Live Filter
function initLiveFilter(columnsToIndex) {
var liveFilter = jQuery("#liveFilter");
if (liveFilter.length > 0) {
var liveFilterField = liveFilter.find("input.liveFilterInput"),
liveFilterGrid = liveFilter.find("table.liveFilterList"),
liveFilterGridRows = liveFilterGrid.find("tr:gt(0)"), // gt(0) prevents the first row (normally a TH) from being included.
liveFilterClear = liveFilter.find(".clearField"),
liveFilterNoResults = liveFilterGrid.prev(),
liveFilterDataArray = new Array(),
//Create an array and populate it with key codes that should not cause shake effects
characterValidationArray = [8, 45, 46], //backspace, insert, delete
//Create an array and populate it with key codes that don't trigger an action
characterExclusionArray = [13, 20, 27, 33, 34, 37, 39, 35, 36, 16, 17, 18, 144, 145]; // enter, caps, esc, page up, page down, left, right, home, end, shift, ctrl, alt, num lock, scroll lock
// Create the datasources we'll use to index the content
if (columnsToIndex.length > 1) {
for (col = 0; col <= columnsToIndex.length - 1; col++) {
liveFilterGridRows.children("td:nth-child(" + columnsToIndex[col] + ")").each(function (i) {
liveFilterDataArray[liveFilterDataArray.length++] = jQuery(this).text();
});
}
} else {
liveFilterGridRows.children("td:first-child").each(function (i) {
liveFilterDataArray[i] = jQuery(this).text();
});
}
// When a key is pressed in the designated input field - do the following:
liveFilterField.on("keyup", function (key) {
// Check the character that was pressed and ensure...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.