Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
not working as expected events via HTML can't be called in script

HTML:

<body>
  <script type="module" src="./script.js"></script>
  <div>Welcome to my first html page...</div>
  <div id="username">Another div tag</div>
  <p>This is a paragraph</p>
  <h1>Working on JS</h1>
  <button onclick="firstFunction()">Click</button>    
</body>

J/S:

function firstFunction() {
  console.log("Hurry")
}        

Getting error:

Uncaught ReferenceError: firstFunction is not defined

    at HTMLButtonElement.onclick (index.html:17)

onclick @ index.html:17

What might be the cause of this error?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Don't import the js script as module. use the following code instead :

<script src="./script.js"></script> `
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!