关于jQuery双事件多重加载的问题。

来源:互联网 发布:外籍院士 知乎 编辑:程序博客网 时间:2024/06/18 02:37

<html><a href="1**.html"><button onclick="buttonEvent()">点击事件</button></a></html>


function buttonEvent(){location.href = "2**.html";}


如代码显示那样,当点击button按钮的时候想跳转到2**.html页面。但是,这个最终执行的结果是,先跳转到2**.html页面,然后再跳转到1**.html页面,最终显示的结果是1**.html页面中的内容。


那么,在function中加入下面的代码才可以达到上面的目的。


function buttonEvent(e){e = e || window.event;e.stopPropagation();e.preventDefault();location.href = "2**.html";}


0 0