2009-09-10 82 views
0

我有以下事件绑定到类“riskInformationButton”的许多超链接。它在Firefox中正常工作,但不在IE中。jquery代码在Firefox中工作,但不是IE

$(".riskInformationButton").bind("click", function(e){ 

    if (e.stopPropagation) e.stopPropagation(); 
    else e.cancelBubble = true; 

    var toggler = $(this).parent().parent().next();   
    while(!toggler.hasClass("spacerRow")){     
     toggler = toggler.toggleClass("hidden").toggleClass("visible").next();   
    } 
}); 

任何帮助将不胜感激。 由于提前,

肖恩

+0

有没有发生任何错误? – rahul 2009-09-10 12:22:36

+0

你的锚标签是什么样的?另外,为什么不把$(“a.riskInformationButton”)?我不知道这是否会影响执行速度,但我个人喜欢在我的jQuery查询字符串中尽可能显式。 – 2009-09-10 12:23:21

+0

- 没有错误。 - ?锚标签都只是正常的锚.. linkText“ – ErnieStings 2009-09-10 12:28:36

回答

4

你说你被绑定到hypelinks。 你应该返回false回调或呼吁e.preventDefault()

这是确定使用绑定,但你可能想使用点击来代替:

$("riskInformationButton").click(function(e) { 
    // your code 
}); 
+0

什么在绑定的差异,点击 和返回false,或使用e.preventDefault()没有工作 应该在哪里e.preventDefault()被调用? – ErnieStings 2009-09-10 12:30:27

+0

e.preventDefault()可以在任何地方调用,您可以在回调函数的开头调用它。 – 2009-09-10 12:42:15

+0

Click是bind(“click”)的缩写,我认为click是更清晰的。 – 2009-09-10 12:45:52

相关问题