IE为什么需要我单击两次

问题描述 投票:2回答:2

我有这个jQuery

    $('.billing_info').click(function(e){
        e.preventDefault();
        if(($('.shipping_selection').length) > 0){
            if ($('.shipping_selection:checked').length == 0){
                $('.hide_error').show();
                $("html, body").animate({ scrollTop: $(".hide_error").offset().top }, "slow");
                $(".hide_error").effect("highlight", {}, 4000);
                return false;
            }else{
                $('.billing_info').unbind("click");
                $('.billing_info').click();
            }   
        }else{
            $('.billing_info').unbind("click");
            $('.billing_info').click();
        }
    });

除IE外,在所有浏览器中都很棒。我正在使用IE8,并且即使单击了一个单选按钮$('。shipping_selection'),用户也需要单击两次按钮才能接受单击事件。

javascript jquery internet-explorer
2个回答
1
投票

也许进行一些重构会有所帮助。仅在需要时才阻止使用default,否则让函数传递给default提交事件。

$('.billing_info').click(function(e){
    if(($('.shipping_selection').length) > 0 && $('.shipping_selection:checked').length == 0){
            e.preventDefault();
            $('.hide_error').show();
            $("html, body").animate({ scrollTop: $(".hide_error").offset().top }, "slow");
            $(".hide_error").effect("highlight", {}, 4000);
            return false;
    }
});

0
投票

第二个事件日志的频率如何?

© www.soinside.com 2019 - 2024. All rights reserved.