简体   繁体   English

为什么此脚本不起作用

[英]Why this script isn't working

After learning basics of C++ i'm now startign to learn Javascript, i just created my first script but it isn't working, and im not able to figure out why. 在学习了C ++的基础知识之后,我现在开始学习Javascript,我刚刚创建了我的第一个脚本,但是它无法正常工作,而且我无法弄清原因。

Here is my index.html code: 这是我的index.html代码:

<head>

<script src="javascript.js"></script>


</head>


<body>

<p id="result">Click button below for result</p>

    <br>

    <button type="button" onClick="math()">Click me</button>

</body>

And here is my javascript.js: 这是我的javascript.js:

function (math) {

document.getElementById("result").innerHTML = 'It works';

} }

Any help appreciated thanks 任何帮助表示感谢

A typo issue. 一个错字问题。 Try this: 尝试这个:

function math() {
    document.getElementById("result").innerHTML = 'It works';
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM