jquery is a quick and easy JavaScript framework, saying that the framework can be directly understood to be the encapsulation of the original underlying so that developers can use this framework to develop quickly.1:jquery is a quick and easy JavaScript framework, saying that the framework can be directly understood as the encapsulation of the original underlying so that developers can use the framework to develop quickly.
2: Event bubbling is supported in every browser today, so-called bubbling can be understood as:
Condition: There is a DIV element in the outer layer, there is a P element in the inner layers, he has two such relations: the div is the parent element of the P element, and P is the child of the outer Div, and there is a relationship between them that contains and is contained.
Event: Now we all bind the same event on these two elements, such as the Click event.
Result: At this point, when we click on the P tag in the inner layer, the click event of the inner element is triggered, and the click event of the outer div is triggered.
3: Some of the elements in the HTML are defined by default properties, such as a element, which is the hyperlink tag that we usually use, the default property of this tag is to implement the page jump.
4: In each event of jquery, there is a default object as an argument to the event (but must be specified), which is the event object, which contains properties and methods for different occasions. As follows:
$ (' P:first '). Click (Function (event) {
The event object can use the
});
5: Sometimes we don't want bubbles or default events to happen, so it takes some jquery methods to block bubbles and default events. There are three ways to prevent different levels of blocking.
A:return False--->in event handler, prevents default behavior and event bubbing.
return false in the handling of events, you can block default events and bubbling events.
B:event.preventdefault ()---> in event handler, prevent default event (allows bubbling).
Event.preventdefault () in the handling of the event, you can block the default event but allow the bubbling event to occur.
C:event.stoppropagation ()---> in event handler, prevent bubbling (allows default behavior).
Event.stoppropagation () in the handling of the event, you can prevent bubbling but allow the default event to occur.
Code such as:
$ ('. Menu Li '). Click (function () {
$ (this). Find (' ul '). Toggle ();
return false;Remove the trial effect
})
jquery blocks bubbling and HTML default actions