I am trying to convert a jQuery event handler to pure javascript. There are many specific selectors on the page, so this was developed using just one document targeting events with this selector:
$(document).on("click", selectorString, function(event) {
Where selector is a list of selectors as the string " .one, .two, .three ".
I am trying to replicate this without jQuery though:
document.addEventListener("click", function(event){ if (elementHasClass(event.target, selectorString) {
But this does not have the desired behavior, because the listener is only in the document element, and not in the selected element inside the document. Can anyone help with this?
source share