I have just started learning javascript and have made a small little program to create an alert when a button is clicked, yet it doesn’t work and I’m not sure why.
Here is my code:
<html>
<head>
<style>
body {
background-color: grey;
color: white;
}
</style>
<script>
const some_action = () => {
window.alert("hi")
}
document.getElementById("btn").addEventListener("click", some_action)
</script>
</head>
<body>
<p>
<button id="btn">click me</button>
</p>
</body>
</html>