0

当我开始输入文件管理器并且行将正确过滤时,我需要做什么?数据库中包含的数据是“欧洲”和“欧洲”,如果我输入“e”,它只显示“欧洲”,但我想显示两个数据,如何做到这一点......

过滤器代码

$(document).ready(function() {

      $("#content").keyup(function(){
    //hide all the rows
          $("#fbody").find("tr").hide();

    //split the current value of searchInput
          var data = this.value.split(" ");
    //create a jquery object of the rows
          var jo = $("#fbody").find("tr");

    //Recusively filter the jquery object to get results.
          $.each(data, function(i, v){
              jo = jo.filter("*:contains('"+v+"')");
          });
        //show the rows that match.
          jo.show();
     //Removes the placeholder text  

      }).focus(function(){
          this.value="";
          $(this).css({"color":"black"});
          $(this).unbind('focus');
      }).css({"color":"#C0C0C0"});

  });

HTML

<html>
<body>

<div>

<form name="welcomeDiv1" id="welcomeDiv1">
<tr>

      <td>
<input type="text" class="textbox_supplier"  name="content" id="content" >
</td>
      <td>
<input type="text" class="textbox_supplier2"  name="content2" id="content2"  ></td>
<td> <input type="submit" class="textbox_supplier7"   value="+"  name="submit" class="comment_button"/></td>

   </tr>
</form>
</div>

<table id="anyid" class="sortable" > 
<thead>
<tr>
  <th data-sort="int" style="width:163px" >Supplier ID </th> 
  <th style="width:327px" >supplier Name </th>
</tr>
</thead>


<tbody id="fbody">
  <tr>
<td width="144px" class="edit_td">
   <input type="text" style="width:127px;margin:1px 0 0" class="editbox" id="supplierid_input" />
</td>
<td width="310px" class="edit_td">
  <input type="text" style="width:172px;margin:1px 0 0" class="editbox" id="suppliername_input"/>
</td>

<td  width="52px"><div class="delete" id="id">x</div></td>

</tbody>

</table>

</body>
</html>
4

1 回答 1

0

我猜你想让它以大写或小写形式显示

$("#content").keyup(function () {
//split the current value of searchInput
var data = this.value.split(" ");
//create a jquery object of the rows
var jo = $("#fbody").find("tr");
if (this.value == "") {
    jo.show();
    return;
}
//hide all the rows
jo.hide();

//Recusively filter the jquery object to get results.
jo.filter(function (i, v) {
    var $t = $(this);
    var matched = true;
    for (var d = 0; d < data.length; ++d) {
        if (data[d].match(/^\s*$/)) {
            continue;
        }

        var regex = new RegExp(data[d].toLowerCase());
        if ($t.text().toLowerCase().replace(/(manual|auto)/g,"").match(regex) === null) {
            matched = false;
        }
    }
    return matched;
})

//show the rows that match.
.show();
})

.focus(function () {
this.value = "";
$(this).css({
    "color": "black"
});
$(this).unbind('focus');
}).css({
"color": "#C0C0C0"
});
于 2013-11-13T14:44:02.003 回答