2011-08-11 36 views
0

我有一個表,其中包含rowspan和rows不包含rowspan的列。我想從下表中讀取日期列。通讀表並顯示日期

我想閱讀2010年1月1日,星期二2010年1月2日,星期二2010年1月3日...等等... 我該怎麼做?

請注意,有一些rowspan和其他列沒有。 enter image description here

回答

0

試試這個 -

var maxcols = 0; 

$('table tr').each(function() { 
    $(this).children().length > maxcols ? maxcols = $(this).children().length : maxcols = maxcols; 
}); 

$('table tr td:first-child').each(function() { 
    if ($(this).text() != '' && $(this).parent().children().length === maxcols) 
     alert($(this).text()); 
}); 

http://jsfiddle.net/ipr101/FyGR6/1/

+0

@learning - 出於興趣,你爲什麼不接受這個答案 - 你是否發現代碼有問題? – ipr101

3
var dates = []; 

$('table tr td:first-child').each(function() { 
    if ($(this).text() != '') 
     dates.push($(this).text()); 
}); 
+0

它seeems哪裏有行跨度,它正在讀取列中的值旁邊的第一列 – learning

+0

它是閱讀保羅和Jim在星期一閱讀時 – learning

+0

您可以發佈表格的html嗎? – ipr101