当前位置:Gxlcms > JavaScript > jQuery判断元素是否是隐藏的代码

jQuery判断元素是否是隐藏的代码

时间:2021-07-01 10:21:17 帮助过:5人阅读

核心代码:
代码如下:
  1. <br>if($("#elem_id").is(":hidden")) <br>{ <br>} <br><br>实例代码1: <br><span><u></u></span> 代码如下:<pre class="brush:php;toolbar:false layui-box layui-code-view layui-code-notepad"><ol class="layui-code-ol"><li><br><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <br><html> <br><head> <br><title> New Document </title> <br><meta name="Generator" content="EditPlus"> <br><meta name="Author" content=""> <br><meta name="Keywords" content=""> <br><meta name="Description" content=""> <br><script type="text/javascript" src="jquery-1.4.2.js"> <br><!-- <br>//--> <br></script> <br><script type="text/javascript"> <br><!-- <br>$(document).ready(function(){ <br>$("#btnToogle").click(function(){ <br>$("#dvTest").toggle(); <br>alert( $("#dvTest").is(":visible")); //判断元素显示或隐藏状态 <br>}); <br>$("#btnTestIs").click(function(e){ <br>// alert( $(e.target).is("input") ); //判断元素的标名称 <br>alert( $("#btnToogle").parent().is("body") ); <br>}); <br>}); <br>//--> <br></script> <br></head> <br><body> <br><input type="button" value="toogle div" id="btnToogle"> <br><div style="width:50px; height:100px; border:solid 1px red; background-color:blue;" id="dvTest"> <br></div> <br><br /> <br><hr /> <br><input type="button" value="toogle div" id="btnTestIs"> <br></body> <br></html> <br> <br><strong>jquery判断div是否隐藏实例</strong> <br><span><u></u></span> 代码如下:<pre class="brush:php;toolbar:false layui-box layui-code-view layui-code-notepad"><ol class="layui-code-ol"><li><br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br><html xmlns="http://www.w3.org/1999/xhtml"> <br><head> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <br><title>绑定函数</title> <br><script src="jquery-1.3.2.js"></script> <br><script> <br>$(document).ready(function(){ <br>var temp= $("#test").is(":hidden");//是否隐藏 <br>var temp1= $("#test").is(":visible");//是否可见 <br>alert(temp) ; <br>alert(temp1) ; <br>}); </script> <br></head> <br><body> <br><p onclick='test()'>刷新测试</p> <br><div id="test" style="display:none"></div> <br></body> <br></html> <br></li><li> </li><li> </li></ol></pre></li></ol></pre>

人气教程排行