tags:

views:

103

answers:

1

I have the following event binded to many hyperlinks with the class "riskInformationButton". It works fine in firefox but not in 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();         
    }
});

Any help would be much appreciated. Thanks in advance,

Shawn

+4  A: 

You said you are binding to hypelinks. You should return false on the callback or call e.preventDefault().

It is ok to use bind but you may want to use click instead:

$("riskInformationButton").click(function(e) {
     // your code
});
Daniel Moura
What's the difference in bind and click?and returning false, or using e.preventDefault() didn't work.where should e.preventDefault() be called?
ErnieStings
e.preventDefault() can be called anywhere, you may call it on the beginning of the callback function.
Daniel Moura
Click is a shorthand for the bind("click") it won't make a difference. I think click is cleaner.
Daniel Moura