描述:选择所有隐藏的元素。
jQuery( ":hidden" )
例:显示出所有隐藏的div元素,并对隐藏的input元素计数。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>hidden demo</title>
<style>
div{
width:70px;
height:40px;
background:#e7f;
margin:5px;
float:left;
}
span{
display:block;
clear:left;
color:red;
}
.starthidden{
display:none;
}
</style>
<script src="./js/jquery-1.9.1.min.js"></script>
</head>
<body>
<span></span>
<div></div>
<div style="display:none;">Hider!</div>
<div></div>
<div class="starthidden">Hider!</div>
<div></div>
<form>
<input type="hidden"/>
<input type="hidden"/>
<input type="hidden"/>
</form>
<span></span>
<script>
var hiddenElements = $("body").find(":hidden").not("script");
$("span:first").text("Found " + hiddenElements.length + " hidden elements total.");
$("div:hidden").show(3000);
$("span:last").text("Found " + $("input:hidden").length + " hidden inputs.");
</script>
</body>
</html>