首頁  >  文章  >  web前端  >  jquery透過select清單選擇框對表格資料進行過濾範例_jquery

jquery透過select清單選擇框對表格資料進行過濾範例_jquery

WBOY
WBOY原創
2016-05-16 16:49:411241瀏覽

jquery透過select清單選擇框對表格資料進行過濾

表格資料

複製程式碼 程式碼如下:


   
       
                
   
   
       
           
       

            Michael
           
       
           
   
Michael
Jackson
Mars
       




 JS過濾程式碼,其中select是動態產生的
 

複製程式碼


程式碼如下: $("#example > thead th").each(function(i) {    $("").attr("data-index", i).html($("")).change(function() {        $("#example > tbody > tr").show().filter(function() {      this).children();            children.each(function(i) {          if (value == $(this).text() || value == "") comb.push(1);            });
  }).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 $( select.append($("").text($(this).text()));
        }
    });
});
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn