Hello There is a working script written in jQuery that highlights the value "No Results" when input non-existing value in the table into the input ("Live Search"). I tried to rewrite it myself, read the documentation, but without success. Running jQuery code:
$(".search").keyup(function () { var search = $(this).val(); $(".list").children().show(); $('#noresults').remove(); if (search) { $(".list").children().not(":containsNoCase(" + search + ")").hide(); $(".list").each(function () { if ($(this).children(':visible').length == 0) $(this).append('<tr class="noresults"><td style="text-align:center; font-size:17px; padding:25px 0 25px 0!important">No Results</td></tr>'); }); } }); $.expr[":"].containsNoCase = function (el, i, m) { var search = m[3]; if (!search) return false; return new RegExp(search, "i").test($(el).text()); }; The script itself, in fact, is taken from here :
Non-working code in pure JS, rewritten by me:
document.getElementByClassName('search').onkeyup = function() { var search = this.value; document.getElementByClassName('list').children().show(); document.getElementById('noresults').remove(); if(search) { document.getElementByClassName('list').children().not(":containsNoCase(" + search + ")").hide(); document.getElementByClassName('list').each = function () { if(this.children(':visible').length == 0) this.append('<tr class="noresults"><td style="text-align:center; font-size:17px; padding:25px 0 25px 0!important">No Results</td></tr>'); } } }; expr[":"].containsNoCase = function (el, i, m) { var search = m[3]; if (!search) return false; return new RegExp(search, "i").test($(el).text()); }; Especially I can not find an alternative to JS for the second function:
expr[":"].containsNoCase = function (el, i, m) { var search = m[3]; if (!search) return false; return new RegExp(search, "i").test($(el).text()); }; Help rewrite it to pure js. Thank you in advance!
containsNoCase- Grundy