zoukankan      html  css  js  c++  java
  • 判断一个元素是否出现

    <!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>
    

      

  • 相关阅读:
    [HDU] 2084 数塔 入门dp
    一些实用的小技术,不定时更新^_^
    上传图片的综合验证
    一个典型web接口处理
    js控制背景音乐播放
    心开始平和起来
    冲突域广播域
    可怜的我的啊~~
    祈祷
    昨夜小楼又东风...
  • 原文地址:https://www.cnblogs.com/zhishaofei/p/4112876.html
Copyright © 2011-2022 走看看