Jquery show/hide table rows

前端 未结 3 1160
盖世英雄少女心
盖世英雄少女心 2020-12-05 10:48

I want to be able to show/hide the rows in a table using jquery. Ideally I want to have buttons above the table to sort the table with.

i.e [Show rows with id:black]

3条回答
  •  心在旅途
    2020-12-05 11:12

    The filter function wasn't working for me at all; maybe the more recent version of jquery doesn't perform as the version used in above code. Regardless; I used:

        var black = $('.black');
        var white = $('.white');
    

    The selector will find every element classed under black or white. Button functions stay as stated above:

        $('#showBlackButton').click(function() {
               black.show();
               white.hide();
        });
    
        $('#showWhiteButton').click(function() {
               white.show();
               black.hide();
        });
    

提交回复
热议问题