Buscador de LI con Jquery
/*
* jQuery makeSearchList Powered by Jodacame
* http://Nexxuz.com
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*/
jQuery.fn.makeSearchList = function() {
input = $('<input type="text" class="search">');
$(input).attr("placeholder","Search here ...");
$(this).prepend(input);
var list = $(this);
$(input)
.change( function () {
var filter = $(this).val();
if(filter) {
$("li",$(list)).hide();
$("li:Contains(" + filter + ")",$(list)).show();
} else {
$("li",$(list)).show();
}
return false;
})
.keyup( function () {
$(this).change();
});
// Creamos la pseudo-funcion Contains
jQuery.expr[":"].Contains = jQuery.expr.createPseudo(function(arg) {
return function( elem ) {
return jQuery(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
};
});
};
//llamar a la funcion
$(document).ready(function() {
$("#lis1").makeSearchList();
$(".lis2").makeSearchList();
});