Javascript 为什么我的简单函数不起作用?
下面是我的HTML代码。我已经尝试了我能做的一切,但是我不能让这个函数工作。提前谢谢Javascript 为什么我的简单函数不起作用?,javascript,html,Javascript,Html,下面是我的HTML代码。我已经尝试了我能做的一切,但是我不能让这个函数工作。提前谢谢 <html> <head> <title>How many fingers?</title> </head> <body> <p>Guess how many fingers I am holding up </p> <!-- <input type="text" id="fingers"> --
<html>
<head>
<title>How many fingers?</title>
</head>
<body>
<p>Guess how many fingers I am holding up </p>
<!-- <input type="text" id="fingers"> -->
<p><input type="text" id="guess"><button id="checkGuess">Guess</button></p>
<script type="text/javascript">
document.getElementById("checkGuess").onlick = function () {
alert("hi!");
}
</script>
</body>
</html>
有多少个手指?
猜猜我举起了多少根手指
猜
document.getElementById(“checkGuess”).onlick=function(){
警惕(“嗨!”);
}
看起来您的拼写有误:
此:document.getElementById(“checkGuess”)。仅单击
应该是:document.getElementById(“checkGuess”).onclick
缺少的“c”可能会解决您的问题。更正:正在工作*