<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>
<div class="menu"><ul>
<li><a class="hide" href="index.html">首页</a></li>
<li><a class="hide" href="page.html">关于我们</a>
<ul>
<li><a href="page.html">关于合作建房</a></li>
<li><a href="page.html">企业文化</a></li>
<li><a href="page.html">企业荣誉</a></li>
<li><a href="page.html">核心理念</a></li>
</ul>
</li>
<li><a class="hide" href="#">合作成功密码</a>
<ul>
<li><a href="page.html">合作模式</a></li>
<li><a href="page.html">加入流程</a></li>
<li><a href="#">团购幸福家</a></li>
<!--链接页面待定,先链接到page03.html-->
</ul>
</li>
<li><a class="hide" href="#">案例参考</a>
<ul>
<li><a href="page.html">成功案例</a></li>
<li><a href="page.html">失败案例</a></li>
<li><a href="page.html">国外案例</a></li>
</ul>
</li>
<li><a class="hide" href="#">区域项目简介</a>
<ul>
<li><a href="page02.html">华南(国际)口腔医疗器械城</a></li>
<li><a href="page02.html">华南(国际)医疗器材产业中心</a></li>
<li><a href="page02.html">清远红场大型购物商场</a></li>
<li><a href="page02.html">佛山鸿业幼儿园</a></li>
<li><a href="page02.html">佛山西樵金果广场</a></li>
<li><a href="page02.html">佛山石湾行政服务中心</a></li>
</ul>
</li>
<li><a class="hide" href="reg.html">我要报名</a> </li>
<li><a class="hide" href="news-list.html">法律保障</a> </li>
<li><a class="hide" href="page.html">联系我们</a> </li>
</ul>
<div class="clear"> </div>
</div> .menu {
font-family: arial, sans-serif
width: 1000px
height: 38px
margin-top: 5px
position:relative
z-index:10
}
.menu ul {
padding: 0
margin: 0
list-style-type: none
position:relative
z-index:10
}
.menu ul li {
width: 125px
height: 38px
float: left
position: relative
background: url(../images/index_09.jpg) no-repeat left
position:relative
z-index:10
}
.menu ul li a {
display: block
text-align: center
text-decoration: none
display: block
height: 38px
color: #bfd9eb
line-height: 33px
font-size: 14px
font-weight: bold
position:relative
z-index:10
}
.menu ul li a:visited {
display: block
text-align: center
text-decoration: none
width: 125px
display: block
height: 38px
line-height: 38px
font-size: 14px
font-weight: bold
position:relative
z-index:10
}
.menu ul li ul {
display: none
position:relative
z-index:10
}
.menu ul li:hover a {
color: #000
background: #fff
border: none
position:relative
z-index:10
}
.menu ul li:hover ul {
display: block
position: absolute
top: 35px
left: 0
border-top: none
}
.menu ul li:hover ul li a {
display: block
background: #fff
color: #000
font-size: 12px
font-weight: normal
text-align: left
padding-left: 10px
border: none
}
.menu ul li:hover ul li a:hover {
background: #008fc3
color: #f00
}