I\'m guessing I have a basic error in thinking but I just can\'t get around it.
I have a couple of text fields which I want to add an EventListener to. I put them all i
I think you have to use querySelectorAll()
that will return all the input
s :
var fields = document.querySelectorAll('#parent input');
And use loop to attach focus
event to every field :
for (var i = 0; i < fields.length; i++) {
fields[i].addEventListener('focus', emptyField, false);
}
Hope this helps.