I Have 2 JavaScript file, and I'm trying to log the "global" variable in the 2nd JavaScript file after I assign a value to the variable in the 1st js file. In the first js file I want to open a new window (another .html file) with the variable that's log-d
main.js: (1st)
var apple;
document.getElementById("next").addEventListener("click", function(){
apple = "apple ";
console.log(apple ); //log: apple
window.open("second.html", "_top");
});
2nd.js:
function test(){
$(document).ready(function(){
console.log(apple); //log: undefined
});