jQuery.fn.extend(object)合并相同单元列

阅读更多
jQuery中$.fn的用法示例介绍

https://www.cnblogs.com/hellman/p/4349777.html


合并相同单元列

$(function() {
$("#container").width($(window).width()-120);
$.fn.extend({
      //表格合并单元格,colIdx要合并的列序号,从0开始
      "rowspan": function (colIdx) {
          return this.each(function () {
              var that;
              $('tr', this).each(function (row) {
                  $('td:eq(' + colIdx + ')', this).each(function (col) {
                      if (that != null && $(this).html() == $(that).html()) {
                          rowspan = $(that).attr("rowSpan");
                          if (rowspan == undefined) {
                              $(that).attr("rowSpan", 1);
                              rowspan = $(that).attr("rowSpan");
                          }
                          rowspan = Number(rowspan) + 1;
                          $(that).attr("rowSpan", rowspan);
                          $(this).hide();
                      } else {
                          that = this;
                      }
                  });
              });
          });
      }
  });
$("#package_list").rowspan(0);
$("#package_list").rowspan(1);
$("#package_list").rowspan(2);
$("#package_list").rowspan(9);
$("#package_list").rowspan(10);
$("#package_list").rowspan(11);
$("#package_list").rowspan(12);
$("#package_list").rowspan(13);
$("#package_list").rowspan(15);

function reload() {
window.location.reload();
}
setInterval(reload, 1000 * 60 * 5)
})

你可能感兴趣的:(jquery)