以下代码在IE9 +,Chrome,Firefox,Safari和IE8中均能正常运行。它总是错误地返回列高为0和宽度。有想法吗?

jQuery版本:1.9.1

$(function ()
{
    $(window).load(function ()
    {
        // Megamenu
        $("#menu-primary > li").one('mouseenter', function (e)
        {
            var tallestColumnHeight = 0,
            submenuPanelTotalWidth = 0;

            $(".dropdown-menu > .dropdown-submenu", this).each(function ()
            {
                $(this).load();

                tallestColumnHeight = Math.max(tallestColumnHeight, $(this).height())
                console.log('tallest column ' + tallestColumnHeight);

                submenuPanelTotalWidth += parseInt($(this).outerWidth(true), 10);
                console.log('panel width ' + submenuPanelTotalWidth);
            }).height(tallestColumnHeight);

            $(".dropdown-menu > .dropdown-submenu", this).parent().width(submenuPanelTotalWidth);
        });
    });
});


该文档类型如下所示:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

最佳答案

如果您使用的是JQuery 2.0:它不再支持IE 8。

10-07 19:32
查看更多