js判断获取元素是否在可视区域
执行var ab = $(".nav_dh")[0]; isElementInViewport(ab)
function isElementInViewport(el) {
//获取元素是否在可视区域
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <=
(window.innerHeight || document.documentElement.clientHeight) &&
rect.right <=
(window.innerWidth || document.documentElement.clientWidth)
);
}