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: Save file
Warning: The 10th of June 2021, we will discontinue the ability to save to Google Drive.You will still be able to access your stored code on Google Drive.
If you have saved a file to Google Drive, you can open it here:
Open file
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).
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com