I have a text input:
<input class="stops" id="stops" onchange="stopsChanged();">
And my current JavaScript looks like:
<script>
function stopsChanged(){
alert();
}
</script>
But when I run my code, I get this error:
ReferenceError: stopsChanged is not defined
Why am I getting this error?
You must include your JS file on the page your <input> is on like
<script type="text/javascript" src="path/to/your/file.js"></script>
Edit:
What probably happens is that you include your JS file after the <input> is loaded in the DOM. This way HTML tries to access your function before it's even there. Try to put your <script> in the <head> of your HTML and make sure it isn't in a .ready() function or something similar to it.
Source of above: Uncaught ReferenceError: myFunction is not defined
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