Init event with event.initEvent - Javascript DOM

Javascript examples for DOM:Event

Description

Init event with event.initEvent

Demo Code

ResultView the demo in separate window

<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 a2 s  .c o m
el = document.getElementById('x');
el.value = 'pancakes';
ev = document.createEvent('Event');
ev.initEvent('change', true, false);
el.dispatchEvent(ev);
    });

      </script> 
   </head> 
   <body> 
      <input type="text" id="x" onchange="console.log('Changed!')">  
   </body>
</html>

Related Tutorials