Wednesday, August 6, 2014

Use variables in one javascript file to other javascript file

1) // first.js
var colorCodes = {

  back  : "#fff",
  front : "#888",
  side  : "#369"

};

2) // second.js
alert (colorCodes.back); // alerts `#fff`
3) Your HTML
<script type="text/javascript" src="first.js"></script> 
<script type="text/javascript" src="second.js"></script> 

No comments:

Post a Comment