Re: [問題] JQuery合併td

看板Ajax作者時間14年前 (2011/11/03 10:59), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串10/10 (看更多)
之所以修改失敗 是某幾個地方沒改到,導致Index錯誤 加上contains應該是找不出css class name(我猜的…有錯在請指正) 完整寫法如下(修改處以白色字表示): : 將欄位為數字的cell,給定一css class name:Number_right, : 然後將No前輩所給的解,改成以下: $($('tr:first td:not(".Number_right")').get().reverse()).each (function(index){ : : // $start為比對目標,指向每一組的首項cell : : var $start = $current = $(this); : : var $next; : : var need_remove = $([]); : : // 逆向所以index要算一下 index = $start.parent().children().not('.Number_right').length - index - 1; : : // 取得同一個column的下一個cell while(($next=$current.parent().next().children().not('.Number_right') .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: 140.125.235.184 ※ 編輯: fr730149 來自: 140.125.235.184 (11/03 11:00)
文章代碼(AID): #1EiWE7TT (Ajax)
文章代碼(AID): #1EiWE7TT (Ajax)