Re: [問題] JQuery合併td
之所以修改失敗
是某幾個地方沒改到,導致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)
討論串 (同標題文章)
完整討論串 (本文為第 10 之 10 篇):
5
10
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章
14
39