开发者

jquery function not working in IE7 only

I have the following jquery code:

开发者_StackOverflow社区
$(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.


i am just guessing...can you try in this way...

$(function() {
    $('.sliding-buttons').click(function(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();

   });
});

or you need to pass event object to called function in this way-

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


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) );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜