Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to access variables in a different script file

// first.js...(first script file)
var colorCodes = {
  back  : "#fff",
  front : "#888",
  side  : "#369"
};

//in another file...(second script file)
alert(colorCodes.back); // alerts `#fff`

//in your html...
<script type="text/javascript" src="first.js"></script> 
<script type="text/javascript" src="second.js"></script>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #access #variables #script #file
ADD COMMENT
Topic
Name
2+6 =