My javascript file just isn't working when I point to it in html

this is the html, it points to a javascript file

<!DOCTYPE html>
<html lang="en">

    <title>Fund me app</title>

    <script src="./index.js" type="text.javascript">

    <button id="connectButton" onclick="connect()"> Connect



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>

Leave a Reply