最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jquery通過(guò)select列表選擇框?qū)Ρ砀駭?shù)據(jù)進(jìn)行過(guò)濾示例

 更新時(shí)間:2014年05月07日 11:49:59   作者:  
這篇文章主要介紹了jquery通過(guò)select列表選擇框?qū)Ρ砀駭?shù)據(jù)進(jìn)行過(guò)濾示例,需要的朋友可以參考下

jquery通過(guò)select列表選擇框?qū)Ρ砀駭?shù)據(jù)進(jìn)行過(guò)濾

表格數(shù)據(jù)

復(fù)制代碼 代碼如下:

<table id="example">
    <thead>
        <tr>
            <th>Name</th>
            <th>Surname</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Michael</td>
            <td>Jordan</td>
        </tr>
        <tr>
            <td>Michael</td>
            <td>Jackson</td>
        </tr>
        <tr>
            <td>Bruno</td>
            <td>Mars</td>
        </tr>
    </tbody>
</table>

 JS過(guò)濾代碼,其中select是動(dòng)態(tài)生成的
 

復(fù)制代碼 代碼如下:

 $("#example > thead th").each(function(i) {
    $("<select />").attr("data-index", i).html($("<option />")).change(function() {
        $("#example > tbody > tr").show().filter(function() {
            var comb = [], children = $(this).children();
            children.each(function(i) {
                var value = $("select[data-index='" + i + "']").val();
                if (value == $(this).text() || value == "") comb.push(1);
            });
            return comb.length != children.length;
        }).hide();
    }).appendTo("body");
});
$("#example > tbody tr").each(function() {
    $(this).children().each(function(i) {
        var that = $(this);
        var select = $("select[data-index='" + i + "']");
        if (!select.children().filter(function() {
            return $(this).text() == that.text();
        }).length) {
            select.append($("<option />").text($(this).text()));
        }
    });
});
 

相關(guān)文章

最新評(píng)論

阿拉尔市| 股票| 万源市| 靖西县| 准格尔旗| 云浮市| 宜城市| 云霄县| 中西区| 斗六市| 文登市| 繁峙县| 琼结县| 商城县| 连城县| 新和县| 太和县| 土默特右旗| 榆中县| 普安县| 青州市| 名山县| 潜山县| 南川市| 张家川| 永修县| 潞西市| 翁牛特旗| 安陆市| 庆云县| 盐边县| 龙陵县| 积石山| 玉龙| 吴旗县| 吉木萨尔县| 永福县| 唐河县| 淅川县| 蛟河市| 黄骅市|