<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title></title> <style type="text/css"> html, body { 3000px; } #ys { background-color: #ff0000; } </style> </head> <body> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <div id="ys">nihao</div> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <p>adsas</p> <script type="text/javascript" src="js/jquery-1.10.2.js"></script> <script type="text/javascript"> $(window).scroll(function () { if ($("#ys").is(check)) { console.log("出现了"); } function check() { var $this = $(this); var $thisOffsetTop = $this.offset().top; var $thisOffsetLeft = $this.offset().left; if ($thisOffsetTop <= $(window).scrollTop() + $(window).height() && $thisOffsetTop + $this.height() >= $(window).scrollTop() && $thisOffsetLeft <= $(window).scrollLeft() + $(window).width() && $thisOffsetLeft + $this.width() >= $(window).scrollLeft()) { return true; } return false; } }); </script> </body> </html>