I have following code
var el = document.querySelectorAll('.block');
console.log(el);
el.addEventListener('click', function () {
alert('hello');
}, false);
However, it returns an error Uncaught TypeError: Object #<NodeList> has no method 'addEventListener'
Why am I getting this error and how can I solve this issue?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…