My button code looks like this:
<button onclick="submitFunction()">Submit</button>
And my function code like this:
function submitFunction() {
alert("example");
}
I've been looking online for an answer and tried a bunch of things, but nothing seems to work. I'm just putting the alert there to see if the function is being called at all. I'm using the following to link the files.
<script src="file.js"></script>
Probably browser can not find your external js file, because of wrong path. Try to put function inside the <head>
section of the page and if worked, The problem is wrong path to js file.
You have to write following javascript
code between <head>
tag and make sure your given javascript file have valid path
.
JavaScript
<script type="text/javascript">
function submitFunction() {
alert("example");
}
</script>
Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With