<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>js</title><script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script><script type="text/javascript">$(document).ready(function () {$(window).scroll(function () {var a = document.getElementById("eq").offsetTop;if (a >= $(window).scrollTop() && a < ($(window).scrollTop()+$(window).height())) {alert("div在可視范圍");}});});</script></head><body><div style="width:1px;height:2000px;"></div><div id="eq" style=" width:100px; height:100px; background-color:Red;">1</div><div style="width:1px;height:2000px;"></div></body></html>以上代碼是小編給大家介紹的使用jQuery判斷Div是否在可視區(qū)域的方法,希望對(duì)大家有所幫助。接下來(lái)一段代碼給大家介紹jquery如何判斷div是否隱藏,具體代碼如下所示:
<!DOCTYPEhtml PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">jquery 如何判斷div是否隱藏|jquery判斷div是否隱藏<htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8" /><title>綁定函數(shù)</title><scriptsrc="jquery-1.3.2.js"></script><script>$(document).ready(function(){vartemp=$("#test").is(":hidden");//是否隱藏vartemp1=$("#test").is(":visible");//是否可見alert(temp) ;alert(temp1) ;});</script></head><body><ponclick='test()'>刷新測(cè)試</p><divid="test" style="display:none"></div></body></html>新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注