关键语句:
if(div.style.display == "none")
div.style.display = "";
else
div.style.display = "none";用display = “none”来隐藏div!
if(div.style.display == "none")
div.style.display = "";
else
div.style.display = "none";用display = “none”来隐藏div!
<style>
.a {border:1px solid red;width:200;height:100;margin-top:100px;margin-left:100px;}
</style>
<div id="div1" class="a">
<input type="button" value="Click" onclick="hidden()">
</div>
<div class="a">
sfsdfdsfdsfsdfsdf
</div>
<script>
function hidden(obj)
{
document.getElementById("div1").style.display="none";
}
</script>不用移动下边的
所以,可能的话,最好不要设置top值!
我也是刚学,如有不对的地方,欢迎各位指出!
//事件函数
function nextToResult(){
var div2 = document.getElementById("div2");//下面的div
document.getElementById("div1").style.visibility="hidden";//上面的div隐藏
div2.style.position = "absolute";
div2.style.top = 0;
div2.style.left = 0; div2.style.visibility="visible";
}但现在的问题是,div2.style.position = "absolute";这句话是什么意思,我不加这句话,div2就移动不了
div.style.display = "";
else
div.style.display = "none";
上面隐藏了,下面的自动就上去了