5.jQuery基本選擇器
阿新 • • 發佈:2018-12-09
<!DOCTYPE html> <html> <head> <title>使用jQuery基本選擇器</title> <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> </head> <body> <div class="clsFrame"> <div id = "divOne"> ID </div> <div class="clsOne"> CLASS </div> <span>SPAN</span> </div> <script src="../jquery.min.js"></script> <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> </body> </html>