因为button标签按钮会提交表单。
解决方法如下:
1、将<button></button>改为<input type="button"> 或者直接在<button>中添加属性 type="button".
2、在button的点击事件中加入“e.preventDefult()”
$('btn').click(function(e){
e.preventDefault();
});
点击button刷新的几种常用代码:
1、<input type=button value=刷新 onclick="history.go(0)">
2、<input type=button value=刷新 onclick="location.reload()">
3、<input type=button value=刷新 onclick="location=location">
4、<input type=button value=刷新 onclick="location.assign(location)">
5、<input type=button value=刷新 onclick="document.execcommand(refresh)">
6、<input type=button value=刷新 onclick="window.navigate(location)">
7、<input type=button value=刷新 onclick="location.replace(location)">
8、<input type=button value=刷新 onclick="window.open(自身的文件,_self)">
9、<input type=button value=刷新 onclick=document.all.webbrowser.execwb(22,1)>
本文探讨了在HTML中使用button标签时遇到的表单提交问题,并提供了多种解决方案,包括更改button类型、使用JavaScript阻止默认行为,以及实现页面刷新的方法。同时,文章列举了多种使用input标签实现页面刷新的代码示例。
9493





