Suppose Now I've a HTML file with
<script type="text/javascript" src="js/first.js"></script>
<script type="text/javascript" src="js/second.js"></script>
Both JS contain sets of functions, how can I access second.js from first.js?
Suppose Now I've a HTML file with
<script type="text/javascript" src="js/first.js"></script>
<script type="text/javascript" src="js/second.js"></script>
Both JS contain sets of functions, how can I access second.js from first.js?
<script> elements are executed in order. You can't access things defined in second.js while first.js is being first executed, but if you define a function in first.js and set it up so that it's called after second.js has been loaded it will see anything defined in second.js. A DOM ready or a "load" event might be a start.
vars in the global scope (outside any functions) are global.