开发者

Read through the table and display the dates

I am having a table that contains columns with rowspan and rows that do not contain rowspan. I want to read the date column from the table below.

I want to read Monday 1 jan 2010, Tuesday 2 jan 2010. Wednesday 3 jan 2010...etc... How can I do开发者_开发百科 that?

Note that there are some columns with rowspan and others not.

Read through the table and display the dates


var dates = [];

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


Try this -

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜