jquery position()。left sometime返回0

时间:2015-03-15 05:30:57

标签: javascript jquery html css

我知道问题 jquery position left return 0 问了太多次,但是在我的情况下它工作在90%而在另外10%中它返回0。

这是我的情况:

我使用css multi-column显示我的html文件,html内容是动态的,我在某些情况下添加更多内容,我使用insertBefore添加我的内容。

这是我添加更多内容的代码:

addString = function(s)
    {
        $(s).insertBefore('#endMarker');
        _columnCount = Math.floor($('#endMarker').position().left/(_windowWidth + _columnGap));

        if(_columnCount < 0)
        {
            rtl = 1;
            _columnCount = (_columnCount * -1);
            informRTL(rtl);
        }
        reportNumberOfPage(_columnCount);

    };

endMarker是html末尾的一个范围。

所以有时我会0获得_columnCount,而在其他情况下会生成正确的数字。

提前tnx。

0 个答案:

没有答案