2015-02-08 80 views
-1

我想搜索我的表中的行,并且表显示基于搜索词的结果,jQuery做的工作但如果您搜索说“你好”但用小写“h”表示不显示该行。我希望它忽略小写字母和大写字母,想知道是否有人能指导我如何做到这一点?搜索并显示lowecase()和uppercase()结果

$('#search').keyup(function() { 
      var data = this.value.split(" "); 
      var rows = $(".Info tbody tr").hide(); 
      if(this.value ==""){ 
       rows.show(); 
       return; 
      } 
      rows.hide(); 
      rows.filter(function(i,v){ 
       var t = $(this); 
       for (var d = 0; d < data.length; d++) { 
        if (t.is(":Contains('" + data[d] + "')")) { 
         return true; 
        } 
       } 
       return false; 
      }).show(); 
     }); 

<table style ="width:95%" class = "patientInfo"> 
        <thead> 
        <tr> 
         <th>Select </th> 
         <th>Patient Name</th> 
         <th>Hospital Number</th> 
         <th>Date of Birth</th> 
        </tr> 
        </thead> 
       </table> 

用户手动输入行因此我只为标题写了HTML。

回答

0

尝试:

  • 使数据的副本,你的过滤器功能,使该文本小写
  • 做基础上,小写字母过滤
+0

我试图做变种T = $(本)的.text()toLowerCase()。它没有用,你的意思是? – user4538609 2015-02-08 17:36:52

+0

尝试复制小写数据[d]。如果你的文本是小写的,但你仍然在搜索'Apple',那么你的运气不好。 – 2015-02-08 17:38:11

+0

对不起,但我仍然困惑,你是什么意思小写数据[d] – user4538609 2015-02-08 17:57:10