I am trying to call a function written in one JavaScript file from another JavaScript file. I have the following code, but it doesn\'t work:
Try changing the order
Because you call js2();
inside js1.js
, so the script js2.js
should be executed before.
In your case, i think it should still work without changing orders like this because you call js2();
inside a function. When this script is executed:
function js1()
{
alert("Hello from js1");
js2();
}
Even the js2.js
is not executed yet, but you do not actually call js2();
at this time.
Just try it to see if it works.