[英]Javascript randomly stopped working
I can't get my Javascript to execute.It randomly stopped working yesterday and I've been messing around to try to get it to work.我无法让我的 Javascript 执行。它昨天随机停止工作,我一直在努力让它工作。 I tried making a simple code to see if it would work but, I have no luck.
我尝试制作一个简单的代码,看看它是否可行,但我没有运气。 Here is the code:
这是代码:
HTML: HTML:
<script type="text/javascript" src="js\hello.js"></script>
<form id="hello" onsubmit="return hello();">
<input type="submit" />
</form>
Javascript (in sub folder called js): Javascript(在名为 js 的子文件夹中):
function hello()
{
alert("HELLO");
return false;
}
It's really annoying me because all of my Javascript codes aren't working but they were working perfectly fine yesterday.这真的让我很恼火,因为我所有的 Javascript 代码都不起作用,但昨天它们运行得很好。 I am not sure what happened...
我不确定发生了什么......
I meant to make an alert I was just wasn't thinking.我想发出警报,我只是没想到。 It still doesn't work anyways.
无论如何它仍然不起作用。 It's like it isn't even calling the function.
就好像它甚至没有调用函数一样。
use alert("HELLO");
使用
alert("HELLO");
instead of echo.而不是回声。 echo is PHP not javascript.
echo 是 PHP 不是 javascript。
If you want to output to a speicific tag then use document.getElementById("idOfTag").innerHTML = "HELLO";
如果你想输出到一个特定的标签然后使用
document.getElementById("idOfTag").innerHTML = "HELLO";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.