Search code examples
jqueryinternet-explorer-7event-propagation

jquery function not working in IE7 only


I have the following jquery code:

$(function() {
    $('.sliding-buttons').click(slidingContent);
});

function slidingContent(e) {
    var boxID = $(this).attr('id'),
        boxName = $(this).attr('name');

    $('.sliding-holder#s-h-' + boxName).css({'display' : 'block'}).addClass('open');
    $('.sliding-content#s-c-' + boxName + '-' + boxID).css({'display' : 'block'}).addClass('open');
    $('.sliding-box#s-b-' + boxName).stop(true, true).animate({
        top:'0'
        },'slow');

    e.stopPropagation();
    e.preventDefault();
}

It's working in all browsers except, naturally, IE7. In IE7 it fails to stop the propagation.

I'm using the latest version of jquery (1.6.2) but have also tried 1.5.2.

I'm really at a loss here; there are no trailing commas (that I can see...) and I can't find the problem. I'd really appreciate some assistance!

MTIA.


Solution

  • If slidingContent is a function, then you may want to treat it like a function, using parenthesis by calling it. Also, since you are referring to the original event inside the slidingContent function, you may need to pass the event as a function parameter (not sure about this though since I never used events like you are using.

    $('.sliding-buttons').click( slidingContent(e) );