开发者

jquery offset method doesn't seem to return whole numbers

When using jquery's offset method on an element to get its top offset from the document, it returns m开发者_运维知识库e the following for example:

1150.3999938964844

Is there a reason why it does that, and doesn't return a whole number?

Thanks


If it has any dimensions defined as percentages (or any parent does really, unless it's out of the flow) for instance....there's no guarantee it's a whole number :)


Is there a reason why it does that, and doesn't return a whole number?

jQuery.fn.offset = function( options ) {

...

parseFloat( ... )

...
  • jQuery source

See also: Floating Point Accuracy Problems at Wikipedia

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜