一、阻止刷新页面
在表单中的提交按钮<button></button>标签改为<input type="button">或者在<button>中添加属性 type="button"
<button type="button" class="update_group"></button>
二、阻止表单的默认提交
1、使用preventDefault()
$("#uploadVideoForm").submit(function(e){ //uploadVideoForm为表单名称
e.preventDefault()
});
2、使用return false;
$("#uploadVideoForm").submit(function(e){//uploadVideoForm为表单名称
return false;
});
本文介绍了如何通过修改HTML按钮类型和使用JavaScript来阻止网页在表单提交时的刷新,以及如何取消表单的默认提交行为,采用preventDefault()方法或return false;实现。
538

被折叠的 条评论
为什么被折叠?



