浅谈jQuery双事件多重加载的问题

时间:2016-10-05    点击:108   

如下所示:

<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"; 
} 

以上就是小编为大家带来的浅谈jQuery双事件多重加载的问题全部内容了,希望大家多多支持本站~

jQuery事件用法详解
js改变html的原有内容实现方法
jQuery 局部div刷新和全局刷新方法总结
jQuery的Cookie封装,与PHP交互的简单实现
jQuery实现手机版页面翻页效果的简单实例
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved