There are two js files file1.js and file2.js.Connected in the same sequence.
File1.js
'use strict'; function func1(){ //some code } function func2(param1){ func1(); //some code } function func3(param1){ //some code } File2.js
'use strict'; $(function () { $('.btn').click(function (e) { var t=$(e.target); func2(t); }); $('.btn2').click(function (e) { func3(e); }); } I get the following errors:
//file2.js
func2 is not defined.
func3 is not defined.
//file1.js
func3 is defined but never used.
Where is my mistake?
func2andfunc3functionsfunc2func3? Also make sure that the File1.js file is successfully downloaded. - Stepan Kasyanenko$(function () {}? - Sergey Gornostaevwindow.func2in the console after the page loads. If it returnsundefined, then either File1.js does not load, or you have syntax errors, or there is a wrapper in File1.js overfunc2. - Stepan Kasyanenko