标签:
1 jQuery(window).load(function() { 2 //alert(1111); 3 var tabs = document.getElementById("_single_table"); 4 var maxCols = 1, vals, counts, starts; 5 for(var cols = maxCols-1; cols >= 0 ; cols--){ 6 counts = 1; 7 vals = ""; 8 for(var i=0; i<tabs.rows.length; i++){ 9 if(vals == tabs.rows[i].cells[cols].innerHTML){ 10 counts++; 11 }else{ 12 if(counts > 1){ //合并 13 starts = i - counts; 14 tabs.rows[starts].cells[cols].rowSpan = counts; 15 for(var j=starts+1; j<i; j++){ 16 tabs.rows[j].cells[cols].style.display = "none"; 17 } 18 counts = 1; 19 } 20 vals = tabs.rows[i].cells[cols].innerHTML; 21 } 22 } 23 if(counts > 1 ){ //合并,最后几行相同的情况下 24 starts = i - counts; 25 tabs.rows[starts].cells[cols].rowSpan = counts; 26 for(var j=starts+1; j<i; j++){ 27 tabs.rows[j].cells[cols].style.display = "none"; 28 } 29 } 30 } 31 32 33 var tab = document.getElementById("_proportion_tb"); 34 var maxCol = 3, val, count, start; 35 for(var col = maxCol-1; col >= 0 ; col--){ 36 count = 1; 37 val = ""; 38 for(var i=0; i<tab.rows.length; i++){ 39 if(val == tab.rows[i].cells[col].innerHTML){ 40 count++; 41 }else{ 42 if(count > 1){ //合并 43 start = i - count; 44 tab.rows[start].cells[col].rowSpan = count; 45 for(var j=start+1; j<i; j++){ 46 tab.rows[j].cells[col].style.display = "none"; 47 } 48 count = 1; 49 } 50 val = tab.rows[i].cells[col].innerHTML; 51 } 52 } 53 if(count > 1 ){ //合并,最后几行相同的情况下 54 start = i - count; 55 tab.rows[start].cells[col].rowSpan = count; 56 for(var j=start+1; j<i; j++){ 57 tab.rows[j].cells[col].style.display = "none"; 58 } 59 } 60 } 61 62 63 var maxCol = 3, val = "", count = 1, start ,col = 6; 64 for(var i=0; i<tab.rows.length; i++){ 65 if(val == tab.rows[i].cells[col].id){ 66 count++; 67 }else{ 68 if(count > 1){ //合并 69 start = i - count; 70 tab.rows[start].cells[col].rowSpan = count; 71 for(var j=start+1; j<i; j++){ 72 tab.rows[j].cells[col].style.display = "none"; 73 } 74 count = 1; 75 } 76 val = tab.rows[i].cells[col].id; 77 } 78 } 79 if(count > 1 ){ //合并,最后几行相同的情况下 80 start = i - count; 81 tab.rows[start].cells[col].rowSpan = count; 82 for(var j=start+1; j<i; j++){ 83 tab.rows[j].cells[col].style.display = "none"; 84 } 85 } 86 87 });
标签:
原文地址:http://www.cnblogs.com/boncdan/p/4921180.html