I just got into web development and decided to create a test project to see how things work.
My html code is:
<!DOCTYPE html>
<html>
<head>
<title>
title
</title>
<script type="text/javascript" src="jstest.js"></script>
</head>
<body>
<h1>heading1</h1>
<button onclick="runcode()">click me</button>
</body>
</html>
And the script is this:
function runcode(){
alert("clicked");
}
I don't exactly know why the script is not working. I have put it right before the to ensure that the button loads first but it still didn't work
alert("clicked")outside the function?<span onclick="runcode()">click me</span>and let us know if that works