Acionando um evento programaticamente com JavaScript
const btn = document.querySelector('.btn');
btn.addEventListener('click', function () {
alert('You clicked a button');
});
const clickEvent = new Event('click');
btn.dispatchEvent(clickEvent);
Javasper