Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何创建在html和js中显示隐藏消息的密码_Javascript_Html - Fatal编程技术网

Javascript 如何创建在html和js中显示隐藏消息的密码

Javascript 如何创建在html和js中显示隐藏消息的密码,javascript,html,Javascript,Html,我不熟悉HTML和js,我目前正在尝试使用它,以便用户输入密码,如果正确,它将显示隐藏的消息。这就是我目前得到的。我不能让它工作 以下是HTML: <form id="form" onsubmit="return false;"> <input type="text" id="userInput" /> <input type="submit" onclick

我不熟悉HTML和js,我目前正在尝试使用它,以便用户输入密码,如果正确,它将显示隐藏的消息。这就是我目前得到的。我不能让它工作

以下是HTML:

<form id="form" onsubmit="return false;">
  <input type="text" id="userInput" />
  <input type="submit" onclick="othername();" />
</form>

<p id="hidden_clue"></p>

很接近,但在
getElementById
上,需要选择要获取的元素的ID

函数othername(){
var pass1=3736.62417618;
var input=document.getElementById(“userInput”).value;
如果(输入==pass1){
document.getElementById(“隐藏的线索”).textContent=“Hello JavaScript!”;
}
}


你几乎快做到了。那条隐藏的线索就是你要把价值放在哪里?谢谢!这看起来很棒!它正在进行堆栈溢出代码段测试,所以应该很好,但由于某些原因,它在我创建这个网站的地方不起作用。你知道这在glitch.com上有用吗?@BenDonohue它对我有用哦,没关系,我成功了。谢谢你的帮助,这真是太有用了!
var pass1 = 3736.62417618;
var input = document.getElementById("userInput").value;
alert(input);

if (input == pass1) {
  document.getElementById("demo").innerHTML = "Hello JavaScript!";
}