I'm trying hard to convert one instruction in jquery to vanilla JS, but no luck.
Original jquery: select multiple classes . Two of them with chid elements. And then listen to a click
$(".submit_params, .filter_topics li, .filter_authors li, .clean_params").on("click", function(event){ ..... })
I tried things like:
document.getElementsByClassName("submit_params filter_topics+li filter_authors+li clean_params").addEventListener('click', function(event){ ... }
And
document.querySelectorAll(".submit_params, .filter_topics li, .filter_authors li, .clean_params").addEventListener("click", function(event) { ... }
In both cases: ERROR -> Uncaught TypeError: document.getElementsByClassName(...).addEventListener is not a function.
UPDATE: Thank you jabaa! Your comment solves the issue, like this:
var my = document.querySelectorAll(".submit_params, .filter_topics li, .filter_authors li, .clean_params");
my.forEach(function(el) {
el.addEventListener("click", function(event) { ... })
})
Thank you!