If you have a Google account, you can save this code to your Google Drive.
Google will ask you to confirm Google Drive access.
Save file as:
If you have saved a file to Google Drive, you can open it here:
This is a p element, in the div element. This is a span element in the p and the div element.
Note: Click on each of the elements above. When clicking on the div element, it will alert that the div element was clicked. When clicking on the p element, it will return both the p and the div element, since the p element is inside the div element.
But when clicking on the span element, it will only return itself, and not the p and the div element (even though its inside these elements). The event.stopPropagation() stops the click event from bubbling to the parent elements.
Tip: Try to remove the event.stopPropagation() line, and click on the span element again (the click event will now bubble up to parent elements).