[ACCEPTED]-How can I use a variable of one <script> in another <script> in javascript?-global
Accepted answer
If the two script tags are on the same page, any 2 variable declared outside of the scope of 1 a function is global to the page.
If the two script tags are on the same page, any 4 variable declared outside of the scope of 3 a function is global to the page. However, it 2 does matter which script is loaded first 1 for some applications.
When you declared a variable inside a <script>
, you 1 can access it anywhere simply by using this:
var myValue= window.yourProperty;
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.