Div.onclick = (function (N){ return function (){ $('#flying'+N).css({visibility:'visible'}); }; })(i);