Show divs based on text search

后端 未结 4 1611
情深已故
情深已故 2020-12-28 15:49

I have a text input search that is supposed to filter divs based on the title of the div. Here is the code that is not working:

$(\'.contact-name\').each(fun         


        
4条回答
  •  情歌与酒
    2020-12-28 16:16

    Luckily jQuery has a Contains selector:

    $('.contact-name').each(function(){
      var txt = $('#search-criteria').val();
      $(this).find('div:contains("'+txt+'")').show()      
    });
    

提交回复
热议问题