Salve,
ho questo codice per filtrare dei risultati:
Tuttavia non mi trova i risultati se cerco in minuscolo ed il risultato e tutto maiuscolo..codice:<script> function UCWords(str) { arrStr = str.split(" "); var strOut = ''; for (i=0;i<arrStr.length;i++) { firstChar = arrStr[i].substring(0,1); remainChar = arrStr[i].substring(1); firstChar = firstChar.toUpperCase(); remainChar = remainChar.toLowerCase(); strOut += firstChar + remainChar + ' '; } // return string, but drop the last space return strOut.substring(0, strOut.length - 1); } $(document).ready(function(){ $("#cerca").bind('keyup',function(){ $("#prodotti").find("p").each(function(){ var cerca = $("#cerca").val(); var ucwords = UCWords(cerca); if(cerca.length >= 1 ){ if( $(this).is(":contains('"+ cerca + "')") ) $(this).css('display',''); else if( $(this).is(":contains('"+ ucwords + "')") ) $(this).css('display',''); else $(this).css('display','none'); }else{ $(this).css('display',''); } }); }); }); </script>
Dove sbaglio?![]()


Rispondi quotando
