JQUERY1.9学习笔记 之可见性过滤器(二) 可见选择器

时间:2023-03-09 08:37:35
JQUERY1.9学习笔记 之可见性过滤器(二) 可见选择器

描述:选择所有可见的元素。

例:点击时让所有的可见的div元素变黄。

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>visible demo</title>
<style>
div{
width:50px;
height:40px;
margin:5px;
border:3px outset green;
float:left;
}
.starthidden{
display:none;
}
</style>
<script src="./js/jquery-1.9.1.min.js"></script>
</head>
<body>
<button>Show hidden to se they don't change</button>
<div></div>
<div class="starthidden"></div>
<div></div>
<div></div>
<div style="display:none;"></div>
<script>
$("div:visible").click(function(){
$(this).css("background","yellow");
});
$("button").click(function(){
$("div:hidden").show("fast");
});
</script>
</body>
</html>

JQUERY1.9学习笔记 之可见性过滤器(二) 可见选择器