jQuery判断元素显示或隐藏, is 函数

<!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"));  //判断元素显示或隐藏状态

		});



		$("#btnTestIs").click(function(e){

//			alert( $(e.target).is("input") );  //判断元素的标名称

			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)