javascript - List view search list filter using jquery -


i have small bugs in search result, here html

    <input type="text" class="form-control" id="populernamekey"> 

list item:

<ul id="destpopuler">   <li class="country">england</li>   <li class="testing"><a href="#">liverpool</a></li>   <li class="testing"><a href="#">london</a></li>   <li class="country">italy</li>   <li class="testing"><a href="#">roma</a></li>   <li class="testing"><a href="#">milan</a></li> </ul> 

and full javascript jsfiddle

nb: [bug] if typing "spain" letter letter, result lost. want still exist , still confused fix it. help? thank you

in code problem when type liverpol lower case first , text value have proper value, upper case first. should same input value , search value text fist.

you can

.tolowercase function

.touppercase funtion

here link reference tolowercase touppercase

$("#populernamekey").on('keyup', function(){ var value = $(this).val().tolowercase(); $("#destpopuler li").each(function () {     if ($(this).text().tolowercase().search(value) > -1) {         $(this).show();         $(this).prev('.country').last().show();     } else {         $(this).hide();     } });    }) 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -