實在搞不懂哪里我的代碼哪里出問題了
<!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>
2018-08-24
psw變量應該放在函數體
2019-01-17
<!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>