so I'm new to Next.js and I was wondering how to use onclick
to call a function from an external file in my public folder.
Here is my index.js
import Head from "next/head"
import Script from "next/script"
export default function Home() {
return (
<div>
<Head>
<Script src="/hello.js"></Script>
</Head>
<p id="hi">Hello World</p>
<button onclick="hello()">Click me</button>
</div>
)
}
Here is my hello.js
function hello() {
document.getElementById("hi").innerHTML = "Hi World";
}
P.S. I will need to export it to static HTML so placing the javascript above the return function will not work.