javascript - FireFox - attach event to dynamically added function? -


i need dynamically attach function div , pass event.

it working in chrome / ie, not firefox.

i getting following error in firefox console: referenceerror: event not defined

how can solved?

codepen: https://codepen.io/dsomekh/pen/yrkmar

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <style> .example{ cursor:pointer; border:1px solid black; text-align:center; } </style>  <script> window.onload = function() {  var div = $( ".example" ); div.click(function() {test(event);});  }  function test (event) {     alert(event); }  </script> <html> <div class="example">when clicking on div, should alert event details. not work in firefox.</div> </html> 

have tried:

div.on("click",function(e) {test(e);}); 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -