Linux教程網
使用jQuery基本選擇器選擇元素:
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>使用jQuery基本選擇器</title>
- <script language="javascript" type="text/javascript"
- src="../Jscript/jquery-1.5.2.js"></script>
- <style type="text/css">
- body{font-size:12px;text-align:center}
- .clsFrame{width:300px;height:100px}
- .clsFrame div,span{display:none;float:left;
- width:65px;height:65px;border:solid 1px #ccc;margin:8px}
- .clsOne{background-color:#eee}
- </style>
- <script type="text/javascript">
- $(function(){ //ID匹配元素
- $("#divOne").css("display","block");
- })
- $(function(){ //元素名匹配元素
- $("div span").css("display","block");
- })
- /* $(function(){ //類匹配元素
- $(".clsFrame .clsOne").css("display","block");
- })*/
- $(function(){ //匹配所有元素
- $("*").css("display","block");
- })
-
- /* $(function(){ //合並匹配元素
- $("#divOne,span").css("display","block");
- })*/
- </script>
- </head>
- <body>
- <div class="clsFrame">
- <div id="divOne">ID</div>
- <div class="clsOne">CLASS</div>
- <span>SPAN</span>
- </div>
- </body>
- </html>
Copyright ©
Linux教程網 All Rights Reserved