过滤不敏感的案例

时间:2018-05-25 02:23:47

标签: javascript php

此代码区分大小写,您是否会提供一些不区分大小写的代码

=============================================== =====================

var $rows = $('tbody > tr'),
    $filters = $('#filter_table input');

$filters.on("keyup", function () {
    var $i = $filters.filter(function () {
        return $.trim(this.value).length > 0;
    }),
        len = $i.length;

    if (len === 0) return $rows.show();

    var cls = '.' + $i.map(function () {
        return this.className
    }).get().join(',.');

    $rows.hide().filter(function () {
        return $('td', this).filter(cls).filter(function () {
            var content = this.textContent,
                inputVal = $i.filter('.' + this.className).val();

            return content.indexOf(inputVal) > -1;

        }).length === len;
    }).show();
});

1 个答案:

答案 0 :(得分:0)

$rows.hide().filter(function () {
    return $('td', this).filter(cls).filter(function () {
        var content = this.textContent,
            inputVal = $i.filter('.' + this.className).val();

        return content.toLowerCase().indexOf(inputVal.toLowerCase()) > -1;

    }).length === len;
}).show();

我们的想法是将两个值都转换为小写并进行比较