this is the html, it points to a javascript file
<!DOCTYPE html>
<html lang="en">
<head>
<title>Fund me app</title>
</head>
<body>
penis
<script src="./index.js" type="text.javascript">
</script>
<button id="connectButton" onclick="connect()"> Connect
</button>
</body>
</html>
this is index.js I’ve pointed the html code to it, but it just doesn’t run
async function connect() {
if (typeof window.ethereum !== "undefinied") {
await window.ethereum.request({ method: "eth_requestAccounts" })
document.getElementById("connectButton").innerHTML = "Connected"
} else {
document.getElementById("connectButton").innerHTML = "Please install metamask"
}
}
When I click on a button, it should run the javascript code – but it doesn’t. Nothing happens?
>Solution :
The type attribute of the script tag should be text/javascript, not text.javascript.
<script src="./index.js" type="text/javascript"></script>