Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 通读表格并显示日期_Javascript_Jquery - Fatal编程技术网

Javascript 通读表格并显示日期

Javascript 通读表格并显示日期,javascript,jquery,Javascript,Jquery,我有一个表,其中包含具有rowspan的列和不包含rowspan的行。我想从下表中读取日期列 我想读2010年1月1日星期一,2010年1月2日星期二。2010年1月3日星期三……等等。。。 我该怎么做 请注意,有些列具有rowspan,有些列不具有rowspan。 试试这个- var maxcols = 0; $('table tr').each(function() { $(this).children().length > maxcols ? maxcols = $(thi

我有一个表,其中包含具有rowspan的列和不包含rowspan的行。我想从下表中读取日期列

我想读2010年1月1日星期一,2010年1月2日星期二。2010年1月3日星期三……等等。。。 我该怎么做

请注意,有些列具有rowspan,有些列不具有rowspan。 试试这个-

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());
});   
试试这个-

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());
});   

看到有行span的地方,它正在读取第一列旁边的列中的值。您可以发布表格的html吗?看到有行span的地方,它正在读取第一列旁边的列中的值。您可以发布表格的html吗?@learning-出于兴趣您为什么不接受此答案-您发现代码有问题吗?@learning-出于兴趣您为什么不接受此答案-您发现代码有问题吗?