怎么才能实现开始的时候div是隐藏的当我把光标挪到下一个文本框中之后上一个文本框的div就会显示!

解决方案 »

  1.   

    <!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>
    <style>
    *{margin:0; padding:0;}
    </style>
    </head><body>
    <input id="text" type="text" />
        <div id="d" style="width:100px; height:100px; background:#000; display:none; color:#fff;">我是显示出来的DIV</div>
    <script>
         var t = document.getElementById('text');

    t.onfocus = function(){
    document.getElementById('d').style.display = 'block';
    };

    t.onblur = function(){
    document.getElementById('d').style.display = 'none';
    };
        </script>
    </body>
    </html>
      

  2.   

    <html>
    <head>
    <title>111</title>
    <script language="javascript">
    function showdiv(){
    document.getElementById("div1").style.visibility="visible";
    }
    </script>
    </head><input type="text" onblur="showdiv()"/><div id="div1" style="visibility:hidden;"/>文字</div><br/>
    <input type="text"/>
    </body>
    </html>