JQuery provides two ways to prevent events from bubbling.
Method 1: event.stopPropagation();
$("#div1").mousedown(function(event){
event.stopPropagation();
});
Method 2: return false;
$("#div1").mousedown(function(event) {
return false;
});
But there is a difference between these two methods. Returning false not only prevents the event from bubbling up, but also prevents the event itself.
event.stopPropagation() only prevents the event from bubbling up, but does not prevent the event itself.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn