<script type="text/javascript">
window.onload = function(){
var i = 0, j = 0;
(function(){
var div = document.getElementsByTagName('div'), input = document.getElementsByTagName('input')[0];
div[0].innerHTML = i++;
input.onclick = function(){
j = i;
div[1].innerHTML = j;
};
window.setTimeout(arguments.callee, 10);
})();
};
</script>
<div></div>
<div></div>
<input type="button" value="change" />