Skip to content

Instantly share code, notes, and snippets.

@shijiaoliang
Forked from simplelife7/visible_area.js
Created March 11, 2016 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shijiaoliang/76cd182cacd01ef7f1f3 to your computer and use it in GitHub Desktop.
Save shijiaoliang/76cd182cacd01ef7f1f3 to your computer and use it in GitHub Desktop.
【JS】判断元素是否在可视区域内
var a = document.getElementById("eq").offsetTop;
if (a >= $(window).scrollTop() && a < ($(window).scrollTop()+$(window).height())) {
alert("div在可视范围");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment