这是我jquery中有问题的部分
var tickerWidth = 0;
var padding = 10;
firstList.find('li').each(function() {
$(this).append(' —');
tickerWidth += $(this).width() + padding;
$('body').prepend($(this).width() + '<br />');
});
firstList
是一个保存
ul
元素。当我在Firefox中运行这个程序时,我会正确地计算出宽度并将其打印到我的页面上。然而,在狩猎中,我得到的宽度要窄得多——大约是
—
未插入…这是某种比赛条件吗?
有什么办法可以解决这个问题吗?也许首先循环并插入HTML实体,然后再次循环以计算宽度?
谢谢
编辑
我先循环,插入HTML实体,然后再执行另一个循环,但值仍然不正确…
我也试过了
outerWidth()
但这没有帮助。