<script type="text/javascript">
var lastname=document.getElementsByName("fangchan");
//!!!!!!!!定义的全局变量,然后在下面的用document.write(lastname.className);测试不行啊
//lastname是object nodelist 不是object HTMLElement
function hidetext(obj)
{
var myname = obj.parentNode;
var mynamevalue = myname.getAttribute("name");
var content = document.getElementById("content");
var mycontent = content.childNodes;
for(var m=0; m< mycontent.length;m++)
{
if(!(mycontent[m].nodeType==3 && !/\S/.test(mycontent[m].nodeValue))){
var myidvalue=mycontent[m].getAttribute("id");
if(myidvalue==mynamevalue){
mycontent[m].style.display="block";
myname.className="on";
if(lastname!=myname) //判断为了重复点击同一个不会把它的样式消掉
{
lastname.className="";
lastname=myname;
}
}
else
mycontent[m].style.display= "none";
}
else
continue;
}
}
</script>
添加回答
举报
0/150
提交
取消