Here button click is triggered
. Since the button
is inside the span
and onclick
event is defined for span
the two alert
are happened.
One is by the button
and
other by its parent
(parent have onclick event and button click is triggered).
To avoid two alert, use this