JS Expansion Closure effect demo Code _javascript tips

Source: Internet
Author: User
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Demo Open Closing effect </title>
<style type= "Text/css" >
table{
border: #0000FF 1px solid;
}
Table td{
border: #0033FF 1px solid;
Background-color: #6699FF;
}
Table TD div{
Background-color: #FFFF99;
Display:none;
}
Table TD a:link,table TD a:visited{
Text-decoration:none;
Color: #993300;
}
. open{
Display:block;
}
. close{
Display:none;
}
</style>
<script type= "Text/javascript" >
Function List () {
var anode = event.srcelement;
Alert (ANode.nextSibling.nodeName)//Take a sibling node easy to get empty text node
var tdnode = Anode.parentnode;
var divnode = tdnode.getelementsbytagname ("div") [0];
var tabnode = document.getelementsbytagname ("table") [0];
var divnodes = tabnode.getelementsbytagname ("div");
for (var x = 0;x < divnodes.length;x++) {
if (Divnodes[x]==divnode) {
if (divnode.classname== "open") {
Divnode.classname= "Close";
}else{
Divnode.classname= "OPEN";
}
}else{
Divnodes[x].classname= "Close";
}
}

alert (divnode.nodename);

}
</script>

<body>
<table>
<tr>
<td>
<a href= "javascript:void (0)" onclick= "list ()" > Buddy menu Lists </a>
<div>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
</div>
</td>
</tr>
<tr>
<td>
<a href= "javascript:void (0)" onclick= "list ()" > Buddy menu Lists </a>
<div>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
</div>
</td>
</tr>
<tr>
<td>
<a href= "javascript:void (0)" onclick= "list ()" > Buddy menu Lists </a>
<div>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
</div>
</td>
</tr>
<tr>
<td>
<a href= "javascript:void (0)" onclick= "list ()" > Buddy menu Lists </a>
<div>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
New white hair witch <br/>
</div>
</td>
</tr>
</table>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.