如何阻止button默认的刷新页面操作

当button在form表单时,点击button会自动触发button的默认事件,也就是刷新当前页面。那么如何阻止呢:

有两种方式:

一:将<button></button>改为<input type="button">  或者直接在<button>中添加属性 type="button".

二:在button的点击事件中

$('btn').click(function(e){

e.preventDefult();

.......

.......

});

阻止冒泡

function sss(event){

event.stopPropagation();

}

原文地址:https://www.cnblogs.com/LYL-8/p/9684959.html