Assigning events to elements with same class name

I got a lot of them…
I thought it would be better to assign them to the element upon loading the page rather and also for learning purposes. (I am still new to JS)