Javascript examples for DOM:Event
Access function inside closures using event
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w w w . j a v a 2s . com (function () { document.getElementById('my').addEventListener("click", a); var val="test"; function a(event){ console.log(val); event.preventDefault(); event.stopPropagation(); } })(); } </script> </head> <body> <a href="#" id="my">test</a> </body> </html>