看板 Ajax 關於我們 聯絡資訊
拜版上前輩所賜,得到合併欄位解。 但如今,只想把非數字的欄位做合併,但怎樣也寫不出來: 目前我的作法: 將欄位為數字的cell,給定一css class name:Number_Right, 然後將No前輩所給的解,改成以下: $($('tr:first td:not(:contains('Number_Right'))').get().reverse()). each(function(index){ : // $start為比對目標,指向每一組的首項cell : var $start = $current = $(this); : var $next; : var need_remove = $([]); : // 逆向所以index要算一下 : index = $start.parent().children().length - index - 1; : // 取得同一個column的下一個cell : while(($next=$current.parent().next().children().eq(index)).length){ : if($start.html() == $next.html()){ : var rs = (parseInt($start.attr('rowspan'), 10) || 1) + 1; : $start.attr('rowspan', rs); : need_remove.push($next); : } : else{ : $start = $next; : } : $current = $next; : } : // 每跑完一個column才移除不要的cell : need_remove.each(function(){ : this.remove(); : }); : }); 不知這樣的寫法,那裡出錯呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 58.99.73.60 ※ 編輯: fr730149 來自: 58.99.73.60 (11/02 19:46)
No:你看要不要試著用原本的code,然後在 11/02 23:12
No:if($start.html() == $next.html()) 改這邊的判斷就好 11/02 23:12