Jquery: Filter dropdown list as you type

前端 未结 8 1757
粉色の甜心
粉色の甜心 2020-12-04 09:46

I have used a prototype plugin which filters the contents of a dropdown as you type. So for example if you typed \'cat\' into the text box, only items containing the substri

8条回答
  •  有刺的猬
    2020-12-04 09:53

    $(document).ready(function() {
      $("#myInput").on("keyup", function() {
        var value = $(this).val().toLowerCase();
        $("#filter *").filter(function() {
          $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
        });
      });
    });
    
    
    

    Filter



    Filter by:

提交回复
热议问题