Home  >  Article  >  Web Front-end  >  How to determine the distance between the document and the top of the browser_jquery

How to determine the distance between the document and the top of the browser_jquery

WBOY
WBOYOriginal
2016-05-16 17:04:441090browse

When I was writing code today, I subconsciously used $("body").scrollTop();

and then I found out when I tested it that it didn't work in IE.

I have encountered this problem before, but I remember it seemed to be solved using $("html").scrollTop();. This time I found that it didn't work either.

After looking online, I found that I should use $(window).scrollTop(); or $(document).scrollTop();

to record it. . I recently read "Javascript Advanced Programming" and found that these things related to distance are very different in various browsers.

I don’t feel this way until I use jQuery.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn