简体   繁体   中英

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.

Here is my index.html code:

<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:

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';
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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