Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Hi @Z3N1X Welcome to Stackoverflow.
To fix your issue try renaming your function to something else,
since like how @jabaa in the comment.
the cookie name is reserved in JS, So you can’ use it

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading