Reputation: 1
I'm trying to add a submit function in my HTML and refer to a js file with my function. The code runs successfully in Chrome but not in IE11. The error message is "submitFunc(event) is undefined". Could anyone help me fix this problem? I have tried everything I can. T.T
function submitFunc(event) {
console.log("Hey what are you looking for? ")
}
<html>
<div>
<input class="btn btn-primary" type="submit" value="submit" onclick="submitFunc(event)">
</div>
</html>
<script type="text/javascript" src="/static/js/main.js"></script>
Upvotes: 0
Views: 5409
Reputation: 11
I don't know if you still need help, but you're loading the JavaScript file after setting up the on-click event. I would assume that means you don't have the function defined yet. I would move the "script" tag before the elements.
Upvotes: 0
Reputation: 13682
It might be that your <script>
tag in outside of the <html>...</html>
block. Try moving it up into the a <head>...</head>
section just after the first <html>
tag.
Upvotes: 2