I have 2 js files: 1.js and 2.js.
In 1.js I have a variable
var test =\'Hello\';
I\'m trying to access the variable in 2.js
<
You can use sessionStorage to store the variable value
$(document).ready(function () {
sessionStorage.setItem('test ', 'Hello');
});
In the next file retrieve it using
$(function () {
function getData(){
var data = sessionStorage.getItem('test');
alert(data );
}
});
Note the file 1.js need to be loaded before 2.js