标签:sam move fun === ++ 单元格 als document tab
<script> function getTable(table1) { var tb = document.getElementById(table1); trL = tb.rows.length; tdL = tb.rows[0].cells.length; var c; var count = 0 for (let td = tdL - 1; td >= 0; td--) { for (var tr = 0; tr < trL; tr++) { if (count !== 0 && c && c !== tb.rows.length - 1) { tr = c } count = findSame(tb, tr, td) if (count !== 0) c = count + 2 if (count === 0) { } else { tb.rows[tr].cells[td].rowSpan = count + 1 for (var i = 1; i <= count; i++) { tb.rows[tr + i].removeChild(tb.rows[tr + i].cells[td]) } } function findSame(tb, tr, td) { count = 0 /*纵向比较*/ function z(tb, tr, td) { if (td === 0) return true if (tb.rows[tr].cells[td - 1].innerHTML === tb.rows[tr + 1].cells[td - 1].innerHTML) { return z(tb, tr, td - 1) } else { return false } } /*横向比较*/ function h(tb, tr, td, ) { if (tb.rows[tr + 1] && tb.rows[tr].cells[td] && tb.rows[tr + 1].cells[td] && tb.rows[tr].cells[td].innerHTML === tb.rows[tr + 1].cells[td].innerHTML) { if (z(tb, tr, td)) { count++ return h(tb, tr + 1, td) } else { return count } } else { return count } } count = h(tb, tr, td) return count } } } } getTable(‘test1‘) </script>
标签:sam move fun === ++ 单元格 als document tab
原文地址:https://www.cnblogs.com/lucy-xyy/p/11698481.html