tr:nth-child(odd){
height:70px
background-color:#0f9
}
tr:nth-child(even){
display:none
height:60px
background-color:#c3c
}
</style>
<script>
window.onload=function(){
核晌 var trs=document.getElementsByTagName("tr")
for(var i=0i<trs.lengthi+=2){
(function(i){
trs[i].onclick=function(){
for(var j=0j<trs.lengthj+=2){
if(j==i){
if(trs[j+1].style.display!="table-row"){
trs[j+1].style.display="table-row"
}else{
改盯锋 trs[j+1].style.display="none"
}
}else{
trs[j+1].style.display="none"
}
}
}
})(i)
}
}
</script>
<table>
<tr><td>点击本行</td></tr>
<tr><td>1</td></tr>
<tr><td>点击本行</td></tr>
<tr><td>2</td></tr>
<tr><td>点击本行</td></tr>则搭
<tr><td>3</td></tr>
<tr><td>点击本行</td></tr>
<tr><td>4</td></tr>
<tr><td>点击本行</td></tr>
<tr><td>5</td></tr>
<tr><td>点击本行</td></tr>
<tr><td>6</td></tr>
</table>
给tr加一个属性兆绝悔id然后用族正javascript获取宏纤对象再修改样式
document.getElementById(tr的id).style.display = "none"
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)