【问题标题】:Filter Table by column in jQuery在jQuery中按列过滤表
【发布时间】:2014-02-14 16:42:32
【问题描述】:

如果整行包含关键字,我有一个 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"
});

【问题讨论】:

    标签: jquery html filter


    【解决方案1】:

    只看你想要的列

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

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

    【讨论】:

    • 老兄,我尝试了所有类型的组合,除了 ":eq"。这工作谢谢你
    猜你喜欢
    • 2011-03-28
    • 1970-01-01
    • 2015-02-26
    • 1970-01-01
    • 1970-01-01
    • 2017-08-20
    • 1970-01-01
    • 2013-07-13
    相关资源
    最近更新 更多