.Maui Blog

Force an onchange event on a select with pure Javascript

Create an Event object and pass it to the dispatchEvent method of the element:

let my_element = document.getElementById('my_select');
let event = new Event('change');
my_element.dispatchEvent(event);
Exit mobile version