Twitter Bootstrap Row Filter / Search Box

后端 未结 2 639
感动是毒
感动是毒 2021-01-30 15:35

I\'m having trouble finding a tutorial on how to create a simple search query, or row filter, for Twitter Bootstrap. I\'ve tried many, I\'m not sure if I\'m doing something wron

2条回答
  •  遥遥无期
    2021-01-30 15:38

    Here's what I use:

    $('input.filter').live('keyup', function() {
        var rex = new RegExp($(this).val(), 'i');
        $('.searchable tr').hide();
            $('.searchable tr').filter(function() {
                return rex.test($(this).text());
            }).show();
        });
    

    To use it, you just create a table, with a tbody with the class "searchable" and then an input with class "filter" somewhere on your page (I prefer to put them in a Bootstrap Popup behind a search icon).

提交回复
热议问题