Overview
I was working on a project and there is a scenario that I have to call a function which is defined in a JavaScript File in another JavaScript File. So, in the code below you can see that how we can call the function in another JavaScript file.
Code:
Step 1: We have the following function in Scripts/Hello JavaScript File:
- function HelloWorld() {
-
- $("#UserMessage").html("Hello World");
- }
Step 2: Now we have to call it in another JavaScript File as named Activity. Follow the code given below to call it:
- $.getScript('/Scripts/Hello.js', function () {
- HelloWorld();
- });