Javascript 如何在html文件中展开和折叠表列?

Javascript 如何在html文件中展开和折叠表列?,javascript,html,css,Javascript,Html,Css,我有一个HTML(带有CSS)文件。它包含有关进度条日志的详细信息 在表中,请参见开始日期cloumn。进度id的开始日期基本相同。考虑开始日期为23-122014 09:2030为20进程ID。我必须在日期23-12-2014 09:20:30中只显示一个流程id,而不是显示20条记录。如果单击此按钮,则剩余的19条记录应展开并显示 我知道javascript中的collapsein。。但我不知道如何在这里实施 我是Javascript新手..帮帮我 <html>

我有一个HTML(带有CSS)文件。它包含有关进度条日志的详细信息

在表中,请参见开始日期cloumn。进度id的开始日期基本相同。考虑开始日期为23-122014 09:2030为20进程ID。我必须在日期23-12-2014 09:20:30中只显示一个流程id,而不是显示20条记录。如果单击此按钮,则剩余的19条记录应展开并显示

我知道javascript中的collapsein。。但我不知道如何在这里实施

我是Javascript新手..帮帮我

    <html>
    <head>
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <body style="background-color: #343131">
    <p class="header">Progress Logs</p>
    <table class="table1">
    <thead>
    <tr>
    <th scope="col">Process Id</th><th scope="col">Start Time</th><th scope="col">End Time</th><th scope="col">Output Type</th><th scope="col">Input File Count</th><th scope="col">Processed file Count</th><th scope="col">No of Accounts</th><th scope="col">No of Processed Accounts</th><th scope="col">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Progress&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th scope="col"></th><th scope="col" style="text-align:left;">Status</th><th scope="col">Failed File Count</th><th scope="col">Summary</th><th scope="col">Error Log</th>
    </tr>
    </thead>
    <tr>
    <td style="white-space:nowrap;color:#2f2;">17438@sdrtbp01</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;12:47:38</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;12:50:04</td><td style="white-space:nowrap;color:#2f2;">pdf</td><td style="white-space:nowrap;color:#2f2;"><a href="javascript:window.alert('[exp_2_229436_1_m3] ');">1</a></td><td style="white-space:nowrap;color:#2f2;">1</td><td style="white-space:nowrap;color:#2f2;">566</td><td style="white-space:nowrap;color:#2f2;">566</td><td style="white-space:nowrap;color:#2f2;">
    <hr class="progress" style="width:100%;color:#2f2;">
    </td><td style="white-space:nowrap;text-align:right;color:#2f2;">100.00%</td><td style="white-space:nowrap;text-align:left;;color:#2f2;">Finished Successfully</td><td style="white-space:nowrap;color:#2f2;" align="center">0</td><td style="white-space:nowrap;color:#2f2;">All the files processed successfully</td><td style="white-space:nowrap;color:#2f2;"><a href="20141223124738_17438@sdrtbp01.xml">
                    View
                </a></td>
    </tr>
    <tr>
    <td style="white-space:nowrap;color:#2f2;">17079@sdrtbp01</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;12:08:09</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;12:10:37</td><td style="white-space:nowrap;color:#2f2;">pdf</td><td style="white-space:nowrap;color:#2f2;"><a href="javascript:window.alert('[exp_2_229436_1_m3] ');">1</a></td><td style="white-space:nowrap;color:#2f2;">1</td><td style="white-space:nowrap;color:#2f2;">566</td><td style="white-space:nowrap;color:#2f2;">566</td><td style="white-space:nowrap;color:#2f2;">
    <hr class="progress" style="width:100%;color:#2f2;">
    </td><td style="white-space:nowrap;text-align:right;color:#2f2;">100.00%</td><td style="white-space:nowrap;text-align:left;;color:#2f2;">Finished Successfully</td><td style="white-space:nowrap;color:#2f2;" align="center">0</td><td style="white-space:nowrap;color:#2f2;">All the files processed successfully</td><td style="white-space:nowrap;color:#2f2;"><a href="20141223120809_17079@sdrtbp01.xml">
                    View
                </a></td>
    </tr>
    <tr>
    <td style="white-space:nowrap;color:#2f2;">16966@sdrtbp01</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;11:58:23</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;12:04:47</td><td style="white-space:nowrap;color:#2f2;">ps</td><td style="white-space:nowrap;color:#2f2;"><a href="javascript:window.alert('[cmsr_2_20140306_1.dat] ');">1</a></td><td style="white-space:nowrap;color:#2f2;">1</td><td style="white-space:nowrap;color:#2f2;">1697</td><td style="white-space:nowrap;color:#2f2;">1697</td><td style="white-space:nowrap;color:#2f2;">
    <hr class="progress" style="width:100%;color:#2f2;">
    </td><td style="white-space:nowrap;text-align:right;color:#2f2;">100.00%</td><td style="white-space:nowrap;text-align:left;;color:#2f2;">Finished Successfully</td><td style="white-space:nowrap;color:#2f2;" align="center">0</td><td style="white-space:nowrap;color:#2f2;">All the files processed successfully</td><td style="white-space:nowrap;color:#2f2;"><a href="20141223115823_16966@sdrtbp01.xml">
                    View
                </a></td>
    </tr>
    <tr>
    <td style="white-space:nowrap;color:#2f2;">16866@sdrtbp01</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;11:50:03</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;11:52:55</td><td style="white-space:nowrap;color:#2f2;">ps</td><td style="white-space:nowrap;color:#2f2;"><a href="javascript:window.alert('[exp_2_229436_1_m3] ');">1</a></td><td style="white-space:nowrap;color:#2f2;">1</td><td style="white-space:nowrap;color:#2f2;">566</td><td style="white-space:nowrap;color:#2f2;">566</td><td style="white-space:nowrap;color:#2f2;">
    <hr class="progress" style="width:100%;color:#2f2;">
    </td><td style="white-space:nowrap;text-align:right;color:#2f2;">100.00%</td><td style="white-space:nowrap;text-align:left;;color:#2f2;">Finished Successfully</td><td style="white-space:nowrap;color:#2f2;" align="center">0</td><td style="white-space:nowrap;color:#2f2;">All the files processed successfully</td><td style="white-space:nowrap;color:#2f2;"><a href="20141223115003_16866@sdrtbp01.xml">
                    View
                </a></td>
    </tr>
    <tr>
    <td style="white-space:nowrap;color:#2f2;">16868@sdrtbp01</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;11:50:02</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;11:50:44</td><td style="white-space:nowrap;color:#2f2;">ps</td><td style="white-space:nowrap;color:#2f2;"><a href="javascript:window.alert('[exp_2_234215_1_m15] ');">1</a></td><td style="white-space:nowrap;color:#2f2;">1</td><td style="white-space:nowrap;color:#2f2;">31</td><td style="white-space:nowrap;color:#2f2;">31</td><td style="white-space:nowrap;color:#2f2;">
    <hr class="progress" style="width:100%;color:#2f2;">
    </td><td style="white-space:nowrap;text-align:right;color:#2f2;">100.00%</td><td style="white-space:nowrap;text-align:left;;color:#2f2;">Finished Successfully</td><td style="white-space:nowrap;color:#2f2;" align="center">0</td><td style="white-space:nowrap;color:#2f2;">All the files processed successfully</td><td style="white-space:nowrap;color:#2f2;"><a href="20141223115002_16868@sdrtbp01.xml">
                    View
                </a></td>
    </tr>

    <tr>
    <td style="white-space:nowrap;color:#2f2;">15589@sdrtbp01</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;09:20:30</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;09:21:09</td><td style="white-space:nowrap;color:#2f2;"></td><td style="white-space:nowrap;color:#2f2;"><a href="javascript:window.alert('');">8</a></td><td style="white-space:nowrap;color:#2f2;">8</td><td style="white-space:nowrap;color:#2f2;">8</td><td style="white-space:nowrap;color:#2f2;">8</td><td style="white-space:nowrap;color:#2f2;">
    <hr class="progress" style="width:100%;color:#2f2;">
    </td><td style="white-space:nowrap;text-align:right;color:#2f2;">100.00%</td><td style="white-space:nowrap;text-align:left;;color:#2f2;">Finished Successfully</td><td style="white-space:nowrap;color:#2f2;" align="center">0</td><td style="white-space:nowrap;color:#2f2;">All the files processed successfully</td><td style="white-space:nowrap;color:#2f2;"><a href="20141223092030_15589@sdrtbp01.xml">
                    View
                </a></td>
    </tr>
    <tr>
    <td style="white-space:nowrap;color:#2f2;">15581@sdrtbp01</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;09:20:30</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;09:21:09</td><td style="white-space:nowrap;color:#2f2;"></td><td style="white-space:nowrap;color:#2f2;"><a href="javascript:window.alert('');">5</a></td><td style="white-space:nowrap;color:#2f2;">5</td><td style="white-space:nowrap;color:#2f2;">9</td><td style="white-space:nowrap;color:#2f2;">9</td><td style="white-space:nowrap;color:#2f2;">
    <hr class="progress" style="width:100%;color:#2f2;">
    </td><td style="white-space:nowrap;text-align:right;color:#2f2;">100.00%</td><td style="white-space:nowrap;text-align:left;;color:#2f2;">Finished Successfully</td><td style="white-space:nowrap;color:#2f2;" align="center">0</td><td style="white-space:nowrap;color:#2f2;">All the files processed successfully</td><td style="white-space:nowrap;color:#2f2;"><a href="20141223092030_15581@sdrtbp01.xml">
                    View
                </a></td>
    </tr>
    </details>
    <tr>
    <td style="white-space:nowrap;color:#2f2;">15578@sdrtbp01</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;09:20:30</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;09:21:07</td><td style="white-space:nowrap;color:#2f2;"></td><td style="white-space:nowrap;color:#2f2;"><a href="javascript:window.alert('');">4</a></td><td style="white-space:nowrap;color:#2f2;">4</td><td style="white-space:nowrap;color:#2f2;">6</td><td style="white-space:nowrap;color:#2f2;">6</td><td style="white-space:nowrap;color:#2f2;">
    <hr class="progress" style="width:100%;color:#2f2;">
    </td><td style="white-space:nowrap;text-align:right;color:#2f2;">100.00%</td><td style="white-space:nowrap;text-align:left;;color:#2f2;">Finished Successfully</td><td style="white-space:nowrap;color:#2f2;" align="center">0</td><td style="white-space:nowrap;color:#2f2;">All the files processed successfully</td><td style="white-space:nowrap;color:#2f2;"><a href="20141223092030_15578@sdrtbp01.xml">
                    View
                </a></td>
    </tr>
    <tr>
    <td style="white-space:nowrap;color:#2f2;">15574@sdrtbp01</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;09:20:30</td><td style="white-space:nowrap;color:#2f2;">23-12-2014&nbsp;09:21:07</td><td style="white-space:nowrap;color:#2f2;"></td><td style="white-space:nowrap;color:#2f2;"><a href="javascript:window.alert('');">2</a></td><td style="white-space:nowrap;color:#2f2;">2</td><td style="white-space:nowrap;color:#2f2;">2</td><td style="white-space:nowrap;color:#2f2;">2</td><td style="white-space:nowrap;color:#2f2;">
    <hr class="progress" style="width:100%;color:#2f2;">
    </td><td style="white-space:nowrap;text-align:right;color:#2f2;">100.00%</td><td style="white-space:nowrap;text-align:left;;color:#2f2;">Finished Successfully</td><td style="white-space:nowrap;color:#2f2;" align="center">0</td><td style="white-space:nowrap;color:#2f2;">All the files processed successfully</td><td style="white-space:nowrap;color:#2f2;"><a href="20141223092030_15574@sdrtbp01.xml">
                    View
                </a></td>
    </tr>
    </table>
</body>
</html>

进度日志

进程IdStart TimeEnd TimeOutput类型输入文件数已处理文件数已处理帐户数未处理帐户数进度状态失败文件数摘要错误日志 17438@sdrtbp0123-12-2014 12:47:3823-12-2014 12:50:04pdf1566566
100.00%成功完成0成功处理所有文件 17079@sdrtbp0123-12-2014 12:08:0923-12-2014 12:10:37pdf1566566
100.00%成功完成0成功处理所有文件 16966@sdrtbp0123-12-2014 11:58:2323-12-2014 12:04:47ps116971697
100.00%成功完成0成功处理所有文件 16866@sdrtbp0123-12-2014 11:50:0323-12-2014 11:52:55ps1566566
100.00%成功完成0成功处理所有文件 16868@sdrtbp0123-12-2014 11:50:0223-12-2014 11:50:44ps13131
100.00%成功完成0成功处理所有文件 15589@sdrtbp0123-12-2014 09:20:3023-12-2014 09:21:09888
100.00%成功完成0成功处理所有文件 15581@sdrtbp0123-12-2014 09:20:3023-12-2014 09:21:09599
100.00%成功完成0成功处理所有文件 15578@sdrtbp0123-12-2014 09:20:3023-12-2014 09:21:07466
100.00%成功完成0成功处理所有文件 15574@sdrtbp0123-12-2014 09:20:3023-12-2014 09:21:07222
100.00%成功完成0成功处理所有文件
我不确定自己是否完全理解您想要实现的目标,但我尝试了一下。这就是你要找的吗

CSS

JS


我不确定自己是否完全理解您想要实现的目标,但我尝试了一下。这就是你要找的吗

CSS

JS


我不确定自己是否完全理解您想要实现的目标,但我尝试了一下。这就是你要找的吗

CSS

JS


我不确定自己是否完全理解您想要实现的目标,但我尝试了一下。这就是你要找的吗

CSS

JS


我想你想要的是一份工作。手风琴是一种用户界面设计,在许多主要图书馆都有。如果您想在原生JS中从头开始构建它,这将需要相当多的努力。我建议你用图书馆来做这个


在这种情况下,20条记录组中的第一条记录将是节标题。默认情况下,节标题将被折叠,单击时将展开并显示rest 19记录。

我想您需要的是一个。手风琴是一种用户界面设计,在许多主要图书馆都有。如果您想在原生JS中从头开始构建它,这将需要相当多的努力。我建议你用图书馆来做这个


在这种情况下,20条记录组中的第一条记录将是节标题。默认情况下,节标题将被折叠,单击时将展开并显示rest 19记录。

我想您需要的是一个。手风琴是一种用户界面设计,在许多主要图书馆都有。如果您想在原生JS中从头开始构建它,这将需要相当多的努力。我建议你用图书馆来做这个


在这种情况下,20条记录组中的第一条记录将是节标题。默认情况下,节标题将被折叠,单击时将展开并显示rest 19记录。

我想您需要的是一个。手风琴是一种用户界面设计,在许多主要图书馆都有。如果您想在原生JS中从头开始构建它,这将需要相当多的努力。我建议你用图书馆来做这个


在这种情况下,20条记录组中的第一条记录将是节标题。默认情况下,节标题将被折叠,单击它将展开并显示rest 19记录。

在JS的帮助下,我如何使用展开和折叠功能

<td id="<ExpandImage>">
   <a href="javascript:void(0);" onclick="javascript:expandAll();">
          <img src="image<forClick>"/>
   </a>
</td>

function expand()
{
    document.getElementById('<ExpandTab>').style.display = 'block';
    document.getElementById('<CollapseTab>').style.display = 'none';
    document.getElementById('<ExpandImage>').innerHTML = '<a href="javascript:void(0);" onclick="javascript:collapse();"><img src="images<collapse>"/></a>';
}

function collapse()
{
    document.getElementById('<ExpandTab>').style.display = 'none';
    document.getElementById('<CollapseTab>').style.display = '';
    document.getElementById('<ExpandImage>').innerHTML = '<a href="javascript:void(0);" onclick="javascript:expand();"><img src="images<Expand>" /></a>';
}

函数展开()
{
document.getElementById(“”).style.display='block';
document.getElementById(“”).style.display='none';
document.getElementById(“”).innerHTML=“”;
}
函数折叠()
{
document.getElementById(“”).style.display='none';
document.getElementById(“”).style.display=“”;
document.getElementById(“”).innerHTML=“”;
}

在JS的帮助下,我是如何使用扩展和折叠功能的

<td id="<ExpandImage>">
   <a href="javascript:void(0);" onclick="javascript:expandAll();">
          <img src="image<forClick>"/>
   </a>
</td>

function expand()
{
    document.getElementById('<ExpandTab>').style.display = 'block';
    document.getElementById('<CollapseTab>').style.display = 'none';
    document.getElementById('<ExpandImage>').innerHTML = '<a href="javascript:void(0);" onclick="javascript:collapse();"><img src="images<collapse>"/></a>';
}

function collapse()
{
    document.getElementById('<ExpandTab>').style.display = 'none';
    document.getElementById('<CollapseTab>').style.display = '';
    document.getElementById('<ExpandImage>').innerHTML = '<a href="javascript:void(0);" onclick="javascript:expand();"><img src="images<Expand>" /></a>';
}

函数展开()
{
document.getElementById(“”).style.display='block';
document.getElementById(“”).style.display='none';
document.getElementById(“”).innerHTML=“”;
}
函数折叠()
{
document.getElementById(“”).style.display='none';
document.getElementById(“”).style.display=“”;
document.getElementById(“”).innerHTML=“”;
}
<td id="<ExpandImage>">
   <a href="javascript:void(0);" onclick="javascript:expandAll();">
          <img src="image<forClick>"/>
   </a>
</td>

function expand()
{
    document.getElementById('<ExpandTab>').style.display = 'block';
    document.getElementById('<CollapseTab>').style.display = 'none';
    document.getElementById('<ExpandImage>').innerHTML = '<a href="javascript:void(0);" onclick="javascript:collapse();"><img src="images<collapse>"/></a>';
}

function collapse()
{
    document.getElementById('<ExpandTab>').style.display = 'none';
    document.getElementById('<CollapseTab>').style.display = '';
    document.getElementById('<ExpandImage>').innerHTML = '<a href="javascript:void(0);" onclick="javascript:expand();"><img src="images<Expand>" /></a>';
}