我有很多行的 html 页面(大约 40000)
<html><body>
<table id="t1">
<tr id="r1" name="1"><td>row 1</td></tr>
<tr id="r2" name="1"><td>row 2</td></tr>
....
<tr id="r50000" name="3"><td>row 30000</td></tr>
</table></body></html>
Run Code Online (Sandbox Code Playgroud)
我需要一种快速的方法来隐藏/显示具有指定名称的行集(10 000 或 20 000)。平台要求:IE8-9 和 Mozila Firefox。我提供了多种方法:使用 tbody、块标签、隐藏行,然后停在其中一种:循环行并隐藏/显示它:
curLevel=root.getAttribute("Name");
var nextElement=curElement.nextElementSibling;
while(nextElement!=null)
{
curElement=nextElement;
nextElement=curElement.nextElementSibling;
if(curElement.tagName=="TR")
{
i++;
childLevel=curElement.getAttribute("Name");
if(childLevel<=curLevel)
break;
curElement.style.display = blockStyle;
}
}
Run Code Online (Sandbox Code Playgroud)
但是这个方法很慢!!大约需要 2 分钟...循环速度很快,最慢的部分是curElement.style.display = blockStyle;每次都重新绘制文档。我可以更改选择行的显示样式 然后显示更改吗?
没有 jQuery 的 PS
我想jfreechart在jsp页面中显示一个图表.我写的代码如下 -
...
<%
ChartCreator chart = new ChartCreator();
chart.createCategoryChart();
%>
<img src = "chart.jpg"/>
Run Code Online (Sandbox Code Playgroud)
其中createCategoryChart()方法创建所需的JPG.它存储在eclipse文件夹中(我没有在我的文件名中放置任何路径).
我无法在jsp页面中查看图表,但是创建了该文件.
我究竟做错了什么?