使用jquery/javascript可折叠表中的数据列。

使用jquery/javascript可折叠表中的数据列。,jquery,css,html,html-table,Jquery,Css,Html,Html Table,如图所示,一些表数据有两个主列标题(th),而另一些表数据有一个主列标题。我很难为这个项目创建一些东西,如果你点击th所有相应的td折叠成垂直形式(就像在任何手风琴中一样,但只是垂直而不是水平) 另外,我已经尝试创建了一个小数学程序,在这个程序中,点击th时,所有相应的td都会高亮显示 Jsfiddle:` var colspan=0; var新闻=0; var stuff=$(this.prevAll(“th”).each(函数)(){ 新闻=$(this.attr(“colspan”); 新

如图所示,一些表数据有两个主列标题(th),而另一些表数据有一个主列标题。我很难为这个项目创建一些东西,如果你点击th所有相应的td折叠成垂直形式(就像在任何手风琴中一样,但只是垂直而不是水平)

另外,我已经尝试创建了一个小数学程序,在这个程序中,点击th时,所有相应的td都会高亮显示

Jsfiddle:`

var colspan=0;
var新闻=0;
var stuff=$(this.prevAll(“th”).each(函数)(){
新闻=$(this.attr(“colspan”);
新闻=parseInt(新闻);
colspan=colspan+新闻;
})
indexofthis=parseInt(indexofthis);
var total=colspan+指数;
colspan=colspan+1;
}

对于(var i=colspan;我不能将表分开吗?很抱歉,我必须在一个表中执行所有操作以保持一致性。你不能将表分开吗?很抱歉,我必须在一个表中执行所有操作以保持一致性。
    var colspan = 0;
    var news = 0;
    var stuff = $(this).prevAll("th").each(function () {
        news = $(this).attr("colspan");
        news = parseInt(news);
        colspan = colspan + news;
    })
    indexofthis = parseInt(indexofthis);
    var total = colspan + indexofthis;
    colspan = colspan + 1;
    }

    for (var i = colspan; i <= total; i++) {
        $("td:nth-child(" + i + ")").css({
            "color": "red"
        });
    }
});`