What's the difference between event.stopPropagation and event.preventDefault?

后端 未结 7 1308
余生分开走
余生分开走 2020-11-22 00:52

They seem to be doing the same thing...
Is one modern and one old? Or are they supported by different browsers?

When I handle events myself (without framework) I

7条回答
  •  别那么骄傲
    2020-11-22 01:34

    $("#but").click(function(event){
    console.log("hello");
      event.preventDefault();
     });
    
    
    $("#foo").click(function(){
     alert("parent click event fired !");
    });
    
    

提交回复
热议问题