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

215
Views
Why i cant execute this code(js in html)?

htmlfile:

<!DOCTYPE html>
<head>
    <script src="script.js"></script>
</head>
<body>
    <div class="q" id="cooki" onclick="cookie()">Accept!</div>
</body>

js:


function cookie() {
    alert("hi");
}

and I even tested with console.log, I used script source in body tags , nothing worked

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Hi @Z3N1X Welcome to Stackoverflow. To fix your issue try renaming your function to something else, since how all of the comments below the answer has said(Thanks for correcting me) when you use the cookie name in the function or variable the onclick thinks your trying to use the document.cookie function. that's why this is happening.

about 4 years ago · Juan Pablo Isaza 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!