How to invoke a jquery method which in another jquery method?
For example:
In a.js, I define a variable var url = "ssh";
In b.js, I want to use url in a.js, how can I use?
4 Answers
As known, a variable in the global scope should be accessible to all scripts loaded after it is declared. Include both JavaScript file in one HTML file, place b.js after a.js so that you can access url variable. Like this
<script type="text/javascript" src="a.js"></script>
<script type="text/javascript" src="b.js"></script>
Comments
See what are you looking for is absolutely accessible in terms of correct ordering and a global variable.
In file a.js you have a global var like this:
var url = "ssh";
Then you can use this var in b.js if a.js is placed before this file or you can say loaded before b.js.
So the order of script files would be:
<script src='a.js'></script>
<script src='b.js'></script>