This article mainly introduces a simple method for JS to Prevent bubble events and default events. If you need it, refer to if
Yes
Inside, then,
There is an onclick event,
There are also onclick events, in order to trigger
When the Click Event of the parent element is not triggered, you need to call the following function:
The Code is as follows:
Function stopBubble (e ){
If (e & e. stopPropagation) {// non-IE
E. stopPropagation ();
}
Else {// IE
Window. event. cancelBubble = true;
}
}
To prevent the triggering of the default event, that is, the default href event, you need to call the following function:
The Code is as follows:
Function stopDefault (e ){
// Block the default browser action (W3C)
If (e & e. preventDefault)
E. preventDefault ();
// Block the default action of the function in IE
Else
Window. event. returnValue = false;
Return false;
}