<script> function test(arg) { document.addEventListener("click", function () { alert(arg); }); } test("hello"); document.addEventListener("click", function () { alert('Bye'); }); </script>