JS - create closure
by ian_smithz
HTML
<div id="message">
</div>
<p>
put a break on div above in inspector tools (on subtree modifications)
</p>
JavaScript
(function() {
var lastFocus = $(':focus');
var showMessage = getClosure("hello? still there?<br />");
window.setInterval(showMessage, 2000);
})();
function getClosure(message) {
function showMessage() {
document.getElementById("message").innerHTML += message;
}
return showMessage;
}