使用jQuery判斷Div是否在可視區(qū)域的方法 判斷div是否可見
更新時(shí)間:2016年02月17日 08:53:12 投稿:mrr
這篇文章主要介紹了使用jQuery判斷Div是否在可視區(qū)域的方法 判斷div是否可見
<!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ì)大家有所幫助。接下來一段代碼給大家介紹jquery如何判斷div是否隱藏,具體代碼如下所示:
<!DOCTYPE
html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
jquery 如何判斷div是否隱藏|
jquery判斷div是否隱藏
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta
http-equiv="Content-Type"
content="text/html;
charset=utf-8" />
<title>綁定函數(shù)</title>
<script
src="jquery-1.3.2.js"></script>
<script>
$(document).ready(function(){
var
temp=
$("#test").is(":hidden");//是否隱藏
var
temp1=
$("#test").is(":visible");//是否可見
alert(temp) ;
alert(temp1) ;
});
</script>
</head>
<body>
<p
onclick='test()'>刷新測試</p>
<div
id="test" style="display:none"></div>
</body>
</html>
相關(guān)文章
jQuery實(shí)現(xiàn)火車票買票城市選擇切換功能
本文通過實(shí)例代碼給大家分享了jQuery實(shí)現(xiàn)火車票買票城市選擇切換功能,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧2017-09-09
jQuery實(shí)現(xiàn)簡單日期格式化功能示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)簡單日期格式化功能,涉及jQuery調(diào)用javascript針對(duì)日期格式轉(zhuǎn)換擴(kuò)展實(shí)現(xiàn)日期格式化功能相關(guān)操作技巧,需要的朋友可以參考下2017-09-09
在jquery中處理帶有命名空間的XML數(shù)據(jù)
如果你在做AJAX應(yīng)用,則你可能經(jīng)常會(huì)用到j(luò)query(或者其他框架)處理服務(wù)返回的數(shù)據(jù)。如果用Jquery處理Json格式,將是相當(dāng)方便的。2011-06-06
淺談jquery點(diǎn)擊label觸發(fā)2次的問題
下面小編就為大家?guī)硪黄獪\談jquery點(diǎn)擊label觸發(fā)2次的問題。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-06-06

