2014-02-14 51 views
1

我有一個jQuery腳本,用於在整行包含關鍵字時過濾表。不過,我想限制它只有一列,並有多個文本框,每列一個。我無法弄清楚這一點。有任何想法嗎?在jQuery中按列過濾表

這裏是腳本 http://jsfiddle.net/ukW2C/

$("#searchInput").keyup(function() { 
    console.log("value=%o", this.value); 
    //split the current value of searchInput 
    var data = this.value.split(" "); 
    //create a jquery object of the rows 
    var jo = $("#fbody").find("tr") 
    //hide all the rows 
    .hide(); 

    //Recusively filter the jquery object to get results. 
    jo.filter(function (i, v) { 
     var $t = $(this); 
     for (var d = 0; d < data.length; ++d) { 
      if ($t.is(":contains('" + data[d] + "')")) { 
       console.log(data[d]); 
       return true; 
      } 
     } 
     return false; 
    }) 
    //show the rows that match. 
    .show(); 
}).focus(function() { 
    this.value = ""; 
    $(this).css({ 
     "color": "black" 
    }); 
    $(this).unbind('focus'); 
}).css({ 
    "color": "#C0C0C0" 
}); 

回答

3

只看看在列要

http://jsfiddle.net/ukW2C/352/

var $t = $(this).children(":eq("+indexColumn+")"); 
+0

傢伙我嘗試了所有類型的組合,除了 「:EQ」。這工作謝謝你 – EGN