1)按钮点击事件 onclick不跳转的情况
给button添加type=“button”,button标签的type默认属性值是submit,不设置默认行为是提交表单,例如下面两个实例,实例1点击按钮时是不会执行跳转的,实例2才会正常跳转到1.html
下面两个实例:
实例1:
<button type="submit" onclick="window.location.href='1.html'"</button>
实例2:
<button type="button" onclick="window.location.href='1.html'"</button>
2)window.location.href 不跳转的情况
以下是登录按钮的跳转事件,在ajax中window.location.href 不跳转也要看看自己的登录按钮 的type类型 要改成 type="button"