最新国产好看的视频,伊人天堂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)論

栾川县| 武威市| 扎兰屯市| 东乌| 东明县| 海淀区| 龙川县| 景宁| 随州市| 安顺市| 沈阳市| 岢岚县| 漳州市| 当雄县| 西青区| 芷江| 麻栗坡县| 台湾省| 罗田县| 溧水县| 伊宁县| 佛学| 杂多县| 寿阳县| 从江县| 武威市| 亚东县| 丹江口市| 宁化县| 墨竹工卡县| 广南县| 施甸县| 庄河市| 田东县| 文化| 石嘴山市| 潜江市| 和田县| 无锡市| 娄烦县| 九江县|