Answers for "jquery serach"

4

search functionality in jquery

<input id="search-date1" class="pull-right" value="" placeholder="Search Material" type="text"/>
  $('#search-date1').keyup(function(){
  var value = this.value.toLowerCase();
  $('.modal_iterator_row').each(function(){
    var id = $(this).text().toLowerCase();
    $(this).toggle(id.indexOf(value) !== -1);
  })
});
Posted by: Guest on April-12-2021
0

serach for a keyword jquery

// Search functionality
function myFunction() {
    // Declare variables
    var input = document.getElementById('myInput'),
        filter = input.value,
        ul = document.getElementById('myUL'),
        lis = ul.getElementsByTagName('li'),
        searchTerms = filter.match(/[a-z]+/gi),
        re, index, li, a;
        
    if (searchTerms) {
        searchTerms = searchTerms.map(function(term) {
            return '(?=.*' + term + ')';
        });
        
        re = new RegExp(searchTerms.join(''), 'i');
    } else {
        re = /./;
    }

    // Loop through all list items, and hide those who don't match the search query
    for (index = 0; index < lis.length; index++) {
        li = lis[index];
        a = li.firstChild;

        if (re.test(a.innerHTML + ' ' + a.getAttribute('data-keywords'))) {
            li.style.display = '';
        } else {
            li.style.display = 'none';
        }
    }
}
Posted by: Guest on February-02-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language