However, in some large web interaction projects today, such as large webgame projects, the influence of JavaScript event bubbling is worth noting. This article uses a simple example to explain the Javascript event bubbling and precautions.
If you don't have any idea about JavaScript event bubbling, let's take a look at my previous blog "introduction and application of JavaScript event bubbling". This article is practical and does not elaborate on the basic knowledge of JavaScript event bubbling too much.
InArticleBefore starting, let's take a look at the following requirement: The following HTML assumes that it describes a web game project package bar (people who have played online games should know what the package bar or item bar is) you can drag the package title bar to any position on the page, and click the "X" button on the right of the title bar to close the display of the package bar. By observing the HTML structure, you can find that the close button is actually a link and is used as a child element of the title bar H5. To drag an element, we want to register the mousedown event with the dragged handle element, and click or click the close button to close the package. Based on this requirement, we will soon get the followingCode.
Xmlns = "http://www.w3.org/1999/xhtml">
×