• 判断一个元素是否出现


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

      

  • 相关阅读:
    Objective-C NSFileManager 文件管理总结
    ScrollView在RelativeLayout失效问题
    解决myeclipse中struts2 bug问题包的替换问题
    SOA究竟是个啥
    Flash--元件和实例
    MyEclipse中加入web项目到tomcat
    [C]if (CONDITION)语句中CONDITION的情况
    GTK经常使用控件之笔记本控件( GtkNotebook )
    org.apache.solr.handler.dataimport.DataImportHandlerException: Data Config problem: 对实体 &quot;characterEn
    Android自动测试之Monkey工具
  • 原文地址:https://www.cnblogs.com/zhishaofei/p/4112876.html
Copyright © 2020-2023  润新知