I have a button and I want it to execute a function when I click it but for some reason it isn't working at all. I think there might be a problem with how I am linking the button to my js file. Here's my HTML:
<!DOCTYPE html>
<html lang = "en-us"></html>
<head>
<script src = "spotifybot.js" charset = "utf-8"></script>
<title>Spotify Login</title>
</head>
<body>
<button id = "login" style = "width: 100px;height: 100px">Login To Spotify</button>
</body>
</html>
And here's my js file:
const loginButton = document.getElementById("login").addEventListener('click', loginToSpotify());
const request = require("request");
function loginToSpotify()
{
console.log("Here");
}
Both the files are in the same folder btw in case you thought that might be the problem.
EDIT: After checking the browser console (I thought I'd be able to check my visual studio console but obviously not), I found the error to be with the "require" keyword
Please login or Register to submit your answer