I have 2 functions from two types of different .js documents.
File1.js
$(document).ready(function Function1(){
var $input = $("#input-country");
$input.typeahead({source:['United States', 'China', 'Germany']});
});
File2.js
$(document).ready(function Function2(){
var $input = $("#input-country");
$input.typeahead({source:['Menu 1', 'Menu 2', 'Menu 3']});
});
I created global js which called 2 functions global.js
Global.js
$(function TestName() {
Function1();
Function2();
});
When importing files, only what is in order works.
<script src="js/File1.js"></script>
<script src="js/File2.js"></script>
In this case, only File1.js works, the second does not.
or
<script src="js/File2.js"></script>
<script src="js/File1.js"></script>
In this case, only File2.js works, the first does not work.
source
share