Fire event with event.dispatchEvent - Javascript DOM

Javascript examples for DOM:Event


Fire event with event.dispatchEvent

Demo Code

ResultView the demo in separate window

      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {/* w  ww  .j  a  v a 2 s  . c o m*/
el = document.getElementById('x');
el.value = 'pancakes';
ev = document.createEvent('Event');
ev.initEvent('change', true, false);

      <input type="text" id="x" onchange="console.log('Changed!')">  

Related Tutorials