function setEvents(selector, ev){ var elements = document.querySelectorAll(selector), x; for (x = 0; x < elements.length; x++){ elements[x].onclick = inform; } }