1. 程式人生 > >9. jQuery可見性過濾選擇器

9. jQuery可見性過濾選擇器

<!DOCTYPE html>
<html>
<head>
    <title>可見性過濾選擇器</title>
     <style type="text/css">
           body{font-size:12px;text-align:center}
           div,span{float:left;border:solid 1px #ccc;
                    margin:8px;width:65px;height:65px}
           .GetFocus{border:solid 1px #666;background-color:#eee}
    </style>
</head>
<body>
    <span style="display:none">Hidden</span>
    <div>Visible</div>

<script src="../jquery.min.js"></script>
<script type="text/javascript">
 	$(function(){
 	 	//增加所有可見元素類別
 	 	//$("span:hidden").show();
 	 	//$("div:visible").addClass("GetFocus");

 	 	//增加所有不可見元素類別
 	 	$("span:hidden").show().addClass("GetFocus");
 	})
</script>
</body>
</html>