过滤表格中的数据

时间:2016-04-28 10:54:10

标签: javascript vbscript

早上好

我有这个JS代码,我想在VB中使用它,但我不知道我想要实现的是如果我正在搜索过滤表中的数据。

$(document).ready(function() {
var activeSystemClass = $('.list-group-item.active');

//something is entered in search form
$('#system-search').keyup( function() {
   var that = this;
    // affect all table rows on in systems table
    var tableBody = $('.table-list-search tbody');
    var tableRowsClass = $('.table-list-search tbody tr');
    $('.search-sf').remove();
    tableRowsClass.each( function(i, val) {

        //Lower text for case insensitive
        var rowText = $(val).text().toLowerCase();
        var inputText = $(that).val().toLowerCase();
        if(inputText != '')
        {
            $('.search-query-sf').remove();
            tableBody.prepend('<tr class="search-query-sf"><td colspan="6"><strong>Searching for: "'
                + $(that).val()
                + '"</strong></td></tr>');
        }
        else
        {
            $('.search-query-sf').remove();
        }

        if( rowText.indexOf( inputText ) == -1 )
        {
            //hide rows
            tableRowsClass.eq(i).hide();

        }
        else
        {
            $('.search-sf').remove();
            tableRowsClass.eq(i).show();
        }
    });
    //all tr elements are hidden
    if(tableRowsClass.children(':visible').length == 0)
    {
        tableBody.append('<tr class="search-sf"><td class="text-muted" colspan="6">No entries found.</td></tr>');
    }
  });
});

0 个答案:

没有答案