以下代码在 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">