Javascript Safari使用jQuery返回不正确的宽度

Javascript Safari使用jQuery返回不正确的宽度,javascript,jquery,safari,Javascript,Jquery,Safari,以下是我的jQuery中有问题的部分 var tickerWidth = 0; var padding = 10; firstList.find('li').each(function() { $(this).append(' &mdash;'); tickerWidth += $(this).width() + padding; $('body').prepend($(this).width() + '<

以下是我的jQuery中有问题的部分

var tickerWidth = 0;
var padding = 10;
firstList.find('li').each(function() {

            $(this).append(' &mdash;');
            tickerWidth += $(this).width() + padding;  

           $('body').prepend($(this).width() + '<br />');

        });
var tickerWidth=0;
var=10;
firstList.find('li').each(function(){
$(this.append('&mdash;');
tickerWidth+=$(this).width()+填充;
$('body').prepend($(this.width()+'
'); });
firstList
是一个包含
ul
元素的变量。当我在Firefox中运行它时,我正确地计算了宽度并将其打印到我的页面上。然而,在Safari中,我得到的宽度要窄得多-大约是
&mdash未插入。。。这是某种比赛条件吗

有什么办法可以解决这个问题吗?也许首先循环并插入html实体,然后再次循环以计算宽度

谢谢

编辑

我先循环,插入html实体,然后再循环,但值仍然不正确


我也试过
outerWidth()
,但没用。

好的,我已经计算好了,虽然有点难看

我没有对实体进行
append()
ing,而是像这样插入它

        $(this).html($(this).html() + ' &mdash;');

这很好。

这确实是一个奇怪的错误。您可能希望将此行为提交到jquery开发邮件列表继续并接受您自己的答案,以便此问题不会在站点中显示为未回答。@ichiban-您必须等待48小时才能接受您自己的答案。