I have 2 files, one HTML, one JavaScript.
JavaScript File (contacts.js):
function add_contact() {
// Rest of Code here
}
HTML File:
<script src="/assets/js/contacts.js" type="javascript/text"></script>
I have a button that when it's clicked, it calls the 'add_contact' function:
<button type="button" class="btn btn-primary" onclick="add_contact();">Save changes</button>
When the JavaScript code is the head of the HTML file, the function works fine. However, now it's part of the external file, it returns the following error:
Uncaught ReferenceError: add_contact is not defined
I feel a bit lost over this one, so any help would be fantastic!
Type should be text/javascript
not javascript/text
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