想做个登录框,为什么不行呀!求解答

来源:9-4 区别getElementByID,getElementsByName,getElementsByTagName

狂四郎

2016-12-29 15:39

<!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=utf-8" />

<title>登录框</title>

</head>

<style>

*{margin:0;padding:0}

#div1{position: absolute;

width:100%;

     height:100%;

background:#999;

opactiy:0;

filter:Alpha(opacity=0);

display:none;

z-index:1000;

}

#div3{width:250px;

      height:150px;

 background:#39F;

 position:absolute;

 top:200px;

 left:40%;

 display:none;

 z-index:1001;

      }

</style>

<script>

function(){

         var oDiv1=document.getElementById("div1");

 var oBtt=document.getElementById("button");

 var oDiv3=document.getElementById("div3");

  

 oBtt.onclick=function(){

 

oDiv1.style.display="block";

 oDiv3.style.display="block";}

 

 

 

 

        

}

</script>

<body>

<div id="div1">

</div>

<div id="div2">

     <input id="button" type="button" value="登陆" />

</div>

<div id="div3">

</div>




</body>

</html>


写回答 关注

1回答

  • 狂四郎
    2016-12-29 16:06:47

    <!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=utf-8" />

    <title>登录框</title>

    </head>

    <style>

    *{margin:0;padding:0}

    #div1{position: absolute;

    width:100%;

         height:100%;

    background:#999;

    display:none;

    z-index:1000;

    }

    #div3{width:250px;

          height:150px;

     background:#39F;

     position:absolute;

     top:200px;

     left:40%;

     display:none;

     z-index:1001;

          }

    </style>

    <script>

    function(){

             var oDiv1=document.getElementById("div1");

     var oBtt=document.getElementById("button");

     var oDiv3=document.getElementById("div3");

      

     oBtt.onclick=function(){

     

    oDiv1.style.display="block";

     oDiv3.style.display="block";}

     

     

     

     

            

    }

    </script>

    <body>

    <div id="div1">

    </div>

    <div id="div2">

         <input id="button" type="button" value="登陆" />

    </div>

    <div id="div3">

    </div>




    </body>

    </html>


JavaScript进阶篇

本课程从如何插入JS代码开始,带您进入网页动态交互世界

469381 学习 · 22585 问题

查看课程

相似问题