Simulate an input event with javascript

Technology

Simulate an input event with javascript

 Simulate the event of an input with javascript wa very easy with the series of javascript events is when we want to simulate a form with script and we need to click on the button to send this form or if we want to simulate the event of a select also works


para google chrome


var contenedorselect=document.getElementById('mat-input-1');

var evt = document.createEvent('HTMLEvents');

        evt.initEvent('input', false, true);

contenedorselect.dispatchEvent(new Event('input'));


para internet explorer


var contenedorselect=document.getElementById('mat-input-2');

var evt = document.createEvent('HTMLEvents');

        evt.initEvent('input', false, true);

contenedorselect.dispatchEvent(evt);



para select

var evt = document.createEvent("HTMLEvents");
        evt.initEvent("change", false, true);
       contenedorselect.dispatchEvent(evt);

Post a Comment

0 Comments