1.
1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 4 <html xmlns="http://www.w3.org/1999/xhtml" > 5 <head> 6 <title>标题页</title> 7 <SCRIPT language="JavaScript"> 8 var i 9 //viewTr是要保留的行ID,sumTr是总的行数 10 function trdisplay(viewTr,sumTr){ 11 for (i = 0; i < sumTr; i++) { 12 eval("document.getElementById('tr_" + (i+1) + "').style.display='none';");//隐藏所有的行 13 } 14 eval("document.getElementById('tr_" + viewTr + "').style.display='';");//显示指定要显示的行 15 } 16 </script> 17 </head> 18 <body> 19 <table width="70%" border="1" cellspacing="0" cellpadding="0"> 20 <tr id="tr_1" onClick="trdisplay(1,5)"> 21 <td>第一行</td> 22 </tr> 23 <tr id="tr_2" onClick="trdisplay(2,5)"> 24 <td>第二行</td> 25 </tr> 26 <tr id="tr_3" onClick="trdisplay(3,5)"> 27 <td>第三行</td> 28 </tr> 29 <tr id="tr_4" onClick="trdisplay(4,5)"> 30 <td>第四行</td> 31 </tr> 32 <tr id="tr_5" onClick="trdisplay(5,5)"> 33 <td>第五行</td> 34 </tr> 35 </table> 36 </body> 37 </html>