用的核心代码
function $(obj){
return document.getElementById(obj);
}
window.onload = function(){
var table = document.getElementById("myTable");
//如果在表格区域内产生单击
table.onclick = function(e){
var e = window.event||e,target = e.srcElement||e.target;
//得到tr
while(target.tagName.toLowerCase() != "tr"){
target = target.parentNode;
}
var i = target.rowIndex;
//单击单行的Tr的话就是控制tr + 1的隐藏和显示
if(i%2 == 0){
var nrs = table.rows[i + 1].parentNode.style;
nrs.display = nrs.display == "none"?"":"none";
}
}
}