Event propagation in JavaScript