I am trying to call a function, let's say 'example()' in an external JS script.
Scripts/examplefile.js
function example() {
console.log('function called');
// blah blah blah
}
console.log('JS file was run');
<html>
<head>
<script src='Scripts/examplefile.js'></script>
</head>
<body>
<button type='button' onClick='example()'>Click me</button>
</body>
</html>
The console does print 'JS file was run' but the button does nothing.
//EDIT// Solution: My actual JS function name was 'checkValidity' which isn't supported or is illegal. Not sure. I changed it to something else and it was working.
Problem recreated:
<html>
<head>
<script>
function checkValidity() {
console.log('function called');
}
console.log('jsok');
</script>
</head>
<body>
<button type='button' onClick='checkValidity()'>Click me</button>
</body>
</html>