<script language="javascript">
function show_div(){
var obj_div=document.getElementById("starlist")
obj_div.style.display=(obj_div.style.display=='none')?'block':'none'
}
function hide_div(){
var obj_div=document.getElementById("starlist")
obj_div.style.display=(obj_div.style.display=='none')?'block':'none'
}
</script>
<a href="javascript:show_div()" >显示/展开</a>
<div id="starlist">
内容<br/>
内容<br/>
内容<br/>
内容<br/>
</div>
这样就可以实现
追问
用jQuery实现,该怎么实现?就是不能弹出的那种,就要一个点击了之后就在下方显示的那种,谢谢!
回答
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gbk" />
<title>StripingTable</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function(){ })
function changeDisplay(){
var helloDivObj = $("#helloDiv")
var buttonObj = $("#btnDisplay")
var val = buttonObj.attr("value")
if(val=="隐藏"){
helloDivObj.hide()
buttonObj.attr("value","显示")
}else{
helloDivObj.show()
buttonObj.attr("value","隐藏")
}
}
-->
</script>
</head>
<body>
<input id="btnDisplay" type="button" value="隐藏" onclick="changeDisplay()"/>
<div id="helloDiv">
Hello,everyone<p></p>
Hello,everytwo<p></p>
Hello,everythree<p></p>
</div>
</bdoy>
</html>
CSS菜单.html 文件代码清单如下:
<!doctype html><html langj="zh">
<head>
<meta charset="utf-8">
<title>CSS菜单</title>
<link rel="stylesheet" href="cssmenu.css">
</head>
<body>
<ul>
<li><a href="">A</a></li>
<li><a href="">B</a>
<ul>
<li><a href="">B1</a></li>
<li><a href="">B2</a></li>
<li><a href="">B3</a></li>
</ul>
</li>
<li><a href="">C</a>
<ul>
<li><a href="">C1</a></li>
<li><a href="">C2</a></li>
<li><a href="">C3</a></li>
</ul>
</li>
<li><a href="">D</li>
</ul>
</body>
</html>
cssmenu.css 文件代码清单如下:
/* cssmenu.css */ul li, ul li:hover ul {
display: block
}
ul li ul {
display: none
}