Add event listener to multiple buttons with the same class

PHOTO EMBED

Mon Jun 29 2020 23:11:09 GMT+0000 (Coordinated Universal Time)

Saved by @mishka #javascript

    btns = document.getElementsByClassName("saveBtn");
    for (var i = 0; i < btns.length; i++) {
        btns[i].addEventListener("click", function () {
			//Add function here
        });
    }
content_copyCOPY

This works for an array of elements with the same class.

example.com