Re: [問題] JQuery合併td
拜版上前輩所賜,得到合併欄位解。
但如今,只想把非數字的欄位做合併,但怎樣也寫不出來:
目前我的作法:
將欄位為數字的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)
推
11/02 23:12, , 1F
11/02 23:12, 1F
→
11/02 23:12, , 2F
11/02 23:12, 2F
討論串 (同標題文章)
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章
14
39