Last active
September 10, 2020 08:08
-
-
Save robozavri/7d887579229cf271dd4f6d59ca958194 to your computer and use it in GitHub Desktop.
#javascript #jquery search in html elements by onkeyup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function(){ | |
| // input type text ZE onkeyup | |
| $('#activitysearch').keyup(function(){ | |
| // მივიღოთ ინპუტ ტეგიდან ყოველ ღილაკის დაჭერაზე მისი მნიშვნელობა, დაბალ რეგისტრში | |
| var val = $(this).val().toLowerCase(); | |
| // მოსაძებნი კომპონენტები დავმალოთ ყველა, რათ გამოვაჩინოთ ისენი რომლებსაც იპოვის | |
| $(".activity").hide(); | |
| // გადავარჩიოთ ყვეალ და თითეულში მოვნახოთ ჩვენი ინპუტის მნიშვნელობა ენთხვევა თუ არა | |
| $(".activity").each(function(){ | |
| // text ში ჩავდოთ ის ტექსტი რაშიც გვინდა ხოლმე რო მოიძებნოს ინპუტიდან აღებული მნიშვნელობა | |
| var text = $(this).find('h2').text().toLowerCase(); | |
| // ვანახოთ თუ რამე იპოვა, .indexOf(val) != -1 ეს მოძებნის | |
| if(text.indexOf(val) != -1) | |
| { | |
| $(this).show(); | |
| } | |
| }); | |
| $(".place").hide(); | |
| $(".place").each(function(){ | |
| var text = $(this).find('h2').text().toLowerCase(); | |
| if(text.indexOf(val) != -1) | |
| { | |
| $(this).show(); | |
| } | |
| }); | |
| }); | |
| }); | |
| // based on | |
| // http://cssdeck.com/labs/simple-search-filter-using-jquery/ | |
| // https://www.w3schools.com/jquery/jquery_filters.asp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment