trigger custom event without jQuery
If you want an exact replication of jQuery's behaviour, you're probably best off digging through the jQuery source code
.
If you just want to do normal event dispatching and listening, see CustomEvent
for how to dispatch an event with custom data and addEventListener
for how to listen to it.
Your example would probably look something like
document.addEventListener('hey', function(customEvent)
{
console.log(customEvent.type + ' ' + customEvent.detail.user); // hey stackoverflow
});
document.dispatchEvent(new CustomEvent('hey', {'detail': {'user': 'stackoverflow'}}));
You can use Custom Events and dispatch them on element you want.