【发布时间】:2013-07-18 00:59:50
【问题描述】:
我已经尝试过这些对代码的 sn-ps,第一个在 IE 和 Chrome 中工作,第二个只在 Chrome 中工作,但它们都不能在 Firefox 中工作。我想要的是阻止页面通过链接转到其他页面
$('.album a').click(function(){
event.returnValue = false;
//other codes
})
$('.album a').click(function(){
event.preventDefault();
//other codes
})
编辑: Ian 的这个 sn-p 对我有用
$('.album a').click(function(e){
e.preventDefault();
//other codes
});
【问题讨论】:
-
您可能会考虑不使用链接,尤其是当您没有将它们用作链接时。您可以使用另一个元素(span 等),如果您愿意,可以使用 css 使其看起来像一个链接。
标签: javascript firefox return-value preventdefault