I have a list of select elements inside a forEach loop and want only the first element which is at index 0.
This element will have a different method, I'm trying to prevent a repetitive code i don't want to create another method just for this single element, I've tried to figure it out but it seems i'm not successful.
var listOfSelect = document.querySelectorAll('select');
listOfSelect.forEach(function(element) {
element.addEventListener('focus', function () {
element.style.backgroundColor = "white";
});
element.addEventListener('blur', function () {
element.style.backgroundColor = "#F0F0E7";
});
element.addEventListener('change', function () { // I would want to get the first element here
//
});
});