EDIT I want the function to be globally accessible
Why does myfunction0 work in the dom ready call and myfunction1 does not work?
external.js file
(function($) {
// functions defined like that works
myfunction0 = function() {
console.log("hello world");
}
// functions defined like that do not work
function myfunction1() {
console.log("hello world");
}
})(jQuery);
index.html
<script>
$(function () {
myfunction0(); // works
myfunction1(); // does not work not defined
})
</script>
Does the first function definition get a global scope whereas the second only a local 'in file' scope?