jQuery样式选择器可以通过$(".test1.test2.tt3")方式,也可以通过$("[class='test1 test2 tt3']")方式,如下实例所示:
实例1:
<html>
<head>
<title>jQuery样式选择器</title>
<script src="jquery-1.7.2.js"></script>
</head>
<body>
<span>Hello World</span>
<div id="tt">China</div>
<div class="test1 test2 tt3">Hello</div>
<div class="test1 test2 tt3">Hello2</div>
</body>
<script>
$(".test1.test2.tt3").css("color", "red");
</script>
</html>
运行结果:
实例2:
<html> <head> <title>jQuery样式选择器</title> <script src="jquery-1.7.2.js"></script> </head> <body> <span>Hello World</span> <div id="tt">China</div> <div class="test1 test2 tt3">Hello</div> <div class="test1 test2 tt3">Hello2</div> </body> <script> $("[class='test1 test2 tt3']").css("color", "#0F0FFF"); </script> </html>
运行结果: