jQuery判斷元素是否是隱藏的代碼
更新時(shí)間:2011年04月24日 23:18:46 作者:
jQuery判斷元素顯示或隱藏, is 函數(shù),需要的朋友可以參考下。
核心代碼:
if($("#elem_id").is(":hidden"))
{
}
實(shí)例代碼1:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script type="text/javascript" src="jquery-1.4.2.js">
<!--
//-->
</script>
<script type="text/javascript">
<!--
$(document).ready(function(){
$("#btnToogle").click(function(){
$("#dvTest").toggle();
alert( $("#dvTest").is(":visible")); //判斷元素顯示或隱藏狀態(tài)
});
$("#btnTestIs").click(function(e){
// alert( $(e.target).is("input") ); //判斷元素的標(biāo)名稱
alert( $("#btnToogle").parent().is("body") );
});
});
//-->
</script>
</head>
<body>
<input type="button" value="toogle div" id="btnToogle">
<div style="width:50px; height:100px; border:solid 1px red; background-color:blue;" id="dvTest">
</div>
<br />
<hr />
<input type="button" value="toogle div" id="btnTestIs">
</body>
</html>
jquery判斷div是否隱藏實(shí)例
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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>
復(fù)制代碼 代碼如下:
if($("#elem_id").is(":hidden"))
{
}
實(shí)例代碼1:
復(fù)制代碼 代碼如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script type="text/javascript" src="jquery-1.4.2.js">
<!--
//-->
</script>
<script type="text/javascript">
<!--
$(document).ready(function(){
$("#btnToogle").click(function(){
$("#dvTest").toggle();
alert( $("#dvTest").is(":visible")); //判斷元素顯示或隱藏狀態(tài)
});
$("#btnTestIs").click(function(e){
// alert( $(e.target).is("input") ); //判斷元素的標(biāo)名稱
alert( $("#btnToogle").parent().is("body") );
});
});
//-->
</script>
</head>
<body>
<input type="button" value="toogle div" id="btnToogle">
<div style="width:50px; height:100px; border:solid 1px red; background-color:blue;" id="dvTest">
</div>
<br />
<hr />
<input type="button" value="toogle div" id="btnTestIs">
</body>
</html>
jquery判斷div是否隱藏實(shí)例
復(fù)制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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插件MixItUp實(shí)現(xiàn)動(dòng)畫過濾和排序
MixItUp過濾排序jQuery插件是一款鼠標(biāo)滑過圖片顯示描述的jQuery過濾排序插件。是一款輕量,但功能強(qiáng)大的 jQuery 插件,提供了對(duì)分類和有序內(nèi)容的美麗的動(dòng)畫過濾和排序功能。特別適合用于作品集網(wǎng)站,畫廊,圖片博客以及任何的分類或有序內(nèi)容。2015-04-04jquery實(shí)現(xiàn)跳到底部,回到頂部效果的簡單實(shí)例(類似錨)
下面小編就為大家?guī)硪黄猨query實(shí)現(xiàn)跳到底部,回到頂部效果的簡單實(shí)例(類似錨)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-07-07淺談Jquery中Ajax異步請(qǐng)求中的async參數(shù)的作用
下面小編就為大家?guī)硪黄獪\談Jquery中Ajax異步請(qǐng)求中的async參數(shù)的作用。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-06-06JQuery中attr屬性和jQuery.data()學(xué)習(xí)筆記【必看】
下面小編就為大家?guī)硪黄狫Query中attr屬性和jQuery.data()學(xué)習(xí)筆記【必看】。小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考,一起跟隨小編過來看看吧2016-05-05