鼠标点击一个div显示一个div隐藏事件
2个回答
展开全部
function show1(){
document.getElementById("anotherDiv").style.display="block";
document.getElementById("thisDiv").style.display="none";
}
function show2(){
document.getElementById("thisDiv").style.display="block";
document.getElementById("anotherDiv").style.display="none";
}
<div onclick="show1()" id="thisDiv" style="border:1px solid red;width:100px;height:100px">thisDiv</div>
<div onclick="show2()" id="anotherDiv" style="border:1px solid blue;width:100px;height:100px;display:none">thisDiv</div>
document.getElementById("anotherDiv").style.display="block";
document.getElementById("thisDiv").style.display="none";
}
function show2(){
document.getElementById("thisDiv").style.display="block";
document.getElementById("anotherDiv").style.display="none";
}
<div onclick="show1()" id="thisDiv" style="border:1px solid red;width:100px;height:100px">thisDiv</div>
<div onclick="show2()" id="anotherDiv" style="border:1px solid blue;width:100px;height:100px;display:none">thisDiv</div>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<!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/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function shwoOrHidden(){
if(document.getElementById("d1").style.display=='block'){
document.getElementById("d1").style.display='none';
document.getElementById("d2").style.display='block';
}else if(document.getElementById("d1").style.display=='none'){
document.getElementById("d1").style.display='block';
document.getElementById("d2").style.display='none';
}
}
</script>
</head>
<body>
<div id="d1" style="height:150px; width:150px; border:1px solid #009900; display:block; position:absolute;" onclick="shwoOrHidden()"></div>
<div id="d2" style="height:150px; width:150px; border:1px solid #FFFF00; display:none; position:absolute; left:200px;" onclick="shwoOrHidden()"></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function shwoOrHidden(){
if(document.getElementById("d1").style.display=='block'){
document.getElementById("d1").style.display='none';
document.getElementById("d2").style.display='block';
}else if(document.getElementById("d1").style.display=='none'){
document.getElementById("d1").style.display='block';
document.getElementById("d2").style.display='none';
}
}
</script>
</head>
<body>
<div id="d1" style="height:150px; width:150px; border:1px solid #009900; display:block; position:absolute;" onclick="shwoOrHidden()"></div>
<div id="d2" style="height:150px; width:150px; border:1px solid #FFFF00; display:none; position:absolute; left:200px;" onclick="shwoOrHidden()"></div>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询