I started to replace all of my jquery code with vanilla javascript, but ran into problems with event handling for dynamic html.
WIth Jquery, I can handle all events for a class as follows:
$(‘div’).on(‘mousedown’, ‘.atomdata’, function (e)
{
});
This would apply to all divs, regardless of when they are added. My application constantly updates html via a websocket, and these events work, I don’t need to do anything except replace the html.
I found that in plain vanilla javascript, when I add an event handler, it only applies to existing elements in the DOM, and does not automatically get applied to new elements that are added to the DOM later.
As far as I can see, JQuery is still indispensable and cannot be replaced by pure javascript. Is this correct?