The code is as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GBK"> <title>Untitled Document</title> <style type="text/css"> a:link, a:visited { text-decoration: none; } dt, dd { margin: 0px; padding-top:10px; } dl { height: 27px; } .open { overflow: visible; } .close { overflow: hidden; } </style> </head> <body> <script type="text/javascript"> </script> <dl class="close"> <dt onclick="listMethod(this)"> <a href="javascript:void(0)">显示条目一</a> </dt> <dd>显示内容1</dd> <dd>显示内容2</dd> <dd>显示内容3</dd> <dd>显示内容4</dd> </dl> <dl class="close"> <dt onclick="listMethod(this)"> <a href="javascript:void(0)">显示条目二</a> </dt> <dd>显示条目二内容1</dd> <dd>显示条目二内容2</dd> <dd>显示条目二内容3</dd> <dd>显示条目二内容4</dd> </dl> <dl class="close"> <dt onclick="listMethod(this)"> <a href="javascript:void(0)">显示条目三</a> </dt> <dd>显示内容1</dd> <dd>显示内容2</dd> <dd>显示内容3</dd> <dd>显示内容4</dd> </dl> <script type="text/javascript"> var flag = true; function listMethod2(){ var dlNode = document.getElementById("dlID");// if (dlNode.style.overflow == visible) {// dlNode.style.overflow = "hidden";// }// else // if (dlNode.style.overflow == hidden) {// dlNode.style.overflow = "visible"// } if (flag) { dlNode.style.overflow = "visible"; flag = false; } else { dlNode.style.overflow = "hidden"; flag = true; } } function listMethod(node){ //var dlNode = document.getElementById("dlID"); //alert(node.nodeName); var dlNode = node.parentNode; if (dlNode.className == "open") { dlNode.className = "close"; } else { dlNode.className = "open"; } } </script> </body></html>
.open { overflow: visible; height: auto; }
.open { overflow: visible; height: auto; }