in a page test.php I'm loading content.php like this:
$(document).on('click', '.test', function () {
$('#content').load('content.php');
});
in content.php I have this Jquery code:
$(function() {
var nb = 10;
$(document).on('click', '.trigger', function () {
alert(nb);
nb +=10;
});
$(document).on('click', '.exit', function () { $('#content').html(''); });
});
when I'm clicking for the first time on #content nb as the value 10 and I can increment it by clicking on it, for exemple I'm clicking 3 times on it so its value is 40. Then I'm closing the div by clicking on .exit, and I'm reloading content.php by clicking on #content. Now I have two alert: nb as the value 10 but it also has the value 40, how come it still has the value 40?