去了这一段时的时候就是正确的<div id="ID_Box" class="box1">22222 <br/>22222 <br/>22222 <br/>22222 </div>
<div class="title" id="test" onclick="OpenCloseBox()">展开 </div> 加上去就不对了
请问要怎么改啊
<div class="title" id="test" onclick="OpenCloseBox()">展开 </div> 加上去就不对了
请问要怎么改啊
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<style>
.box1{background:#dedede;font-size:14px;height:50px; width:400px;}
.box2{background:#f00;height:50px; width:400px;}
.title{background:#ccc;margin:10px 0px;cursor:pointer; line-height:25px;width:400px; cursor:pointer;}
</style>
</HEAD> <BODY>
<div id="ID_Box1" class="box1">111111111 <br/>111111111 <br/>11111111111 <br/>11111111111111 </div>
<div class="title" id="test1" onclick="OpenCloseBox('test1','ID_Box1')">展开 </div> <div id="ID_Box2" class="box1">22222 <br/>22222 <br/>22222 <br/>22222 </div>
<div class="title" id="test2" onclick="OpenCloseBox('test2','ID_Box2')">展开 </div> <script language="javascript">
function OpenCloseBox(testid,boxid){
if (document.getElementById(testid).innerHTML == "展开 "){
document.getElementById(boxid).className="box1";
document.getElementById(testid).innerHTML = "收缩 ";
}else {
document.getElementById(boxid).className="box2";
document.getElementById(testid).innerHTML = "展开 ";
}
}
</script> </BODY>
</HTML>
<style>
.box1{background:#dedede;font-size:14px;height:50px; width:400px;}
.box2{background:#f00;height:50px; width:400px;}
.title{background:#ccc;margin:10px 0px;cursor:pointer; line-height:25px;width:400px; cursor:pointer;}
</style> <div id="ID_Box" class="box1">111111111 <br/>111111111 <br/>11111111111 <br/>11111111111111 </div>
<div class="title" id="test" onclick="OpenCloseBox()">展开 </div> <div id="ID_Box1" class="box1">22222 <br/>22222 <br/>22222 <br/>22222 </div>
<div class="title" id="test1" onclick="OpenCloseBox1()">展开 </div> <script language="javascript">
function OpenCloseBox(){
if (document.getElementById("test").innerHTML == "展开 "){
document.getElementById("ID_Box").className="box1";
document.getElementById("test").innerHTML = "收缩 ";
}else {
document.getElementById("ID_Box").className="box2";
document.getElementById("test").innerHTML = "展开 ";
}
}
function OpenCloseBox1(){
if (document.getElementById("test1").innerHTML == "展开 "){
document.getElementById("ID_Box1").className="box1";
document.getElementById("test1").innerHTML = "收缩 ";
}else {
document.getElementById("ID_Box1").className="box2";
document.getElementById("test1").innerHTML = "展开 ";
}
}
</script>
最简单的方法,再写一个OpenloseBox2()函数不就行了
<style>
.box1{background:#dedede;font-size:14px;height:50px; width:400px;}
.box2{background:#f00;height:50px; width:400px;}
.title{background:#ccc;margin:10px 0px;cursor:pointer; line-height:25px;width:400px; cursor:pointer;}
</style> <div id="ID_Box" class="box2">111111111 <br/>111111111 <br/>11111111111 <br/>11111111111111 </div>
<div class="title" id="test" onclick="OpenCloseBox()">展开 </div> <div id="ID_Box1" class="box1">22222 <br/>22222 <br/>22222 <br/>22222 </div>
<div class="title" id="test1" onclick="OpenCloseBox1()">展开 </div> <script language="javascript">
function OpenCloseBox(){
if (document.getElementById("test").innerHTML == "展开 "){
document.getElementById("ID_Box").className="box1";
document.getElementById("test").innerHTML = "收缩 ";
}else {
document.getElementById("ID_Box").className="box2";
document.getElementById("test").innerHTML = "展开 ";
}
}
function OpenCloseBox1(){
if (document.getElementById("test1").innerHTML == "展开 "){
document.getElementById("ID_Box1").className="box1";
document.getElementById("test1").innerHTML = "收缩 ";
}else {
document.getElementById("ID_Box1").className="box2";
document.getElementById("test1").innerHTML = "展开 ";
}
}
</script>