问答详情
源自:6-3 鼠标经过事件(onmouseover)

实在搞不懂哪里我的代码哪里出问题了

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title> 鼠标经过事件 </title>

<script type="text/javascript">

    var psw=document.getElementById("psd");

    function message(){

    if(psw.value==""){    

      confirm("请输入密码后,再单击确定!"); }

    }

</script>

</head>

<body>

<form>

密码:<input id="psd" name="password" type="password" >

<input name="确定" type="button" value="确定" onmouseover="message()"/>

</form>

</body>

</html>


提问者:lllmh 2018-08-24 13:57

个回答

  • 慕粉4019690
    2018-08-24 17:46:57
    已采纳

    psw变量应该放在函数体

  • 1frgdhf
    2019-01-17 10:56:35

    <!DOCTYPE HTML>


    <html>


    <head>


    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


    <title> 鼠标经过事件 </title>


    <script type="text/javascript">





        function message(){

     var psw=document.getElementById("psd");

      if(psw.value==""){    


         confirm("请输入密码后,再单击确定!"); }


        }


    </script>


    </head>


    <body>


    <form>


    密码:<input id="psd" name="password" type="password"  >


    <input name="确定" type="button" value="确定" onclick="message()"/>


    </form>


    </body>


    </html>