<!DOCTYPE html>
<html>
<head>
<style>
div,span
,p{
width:
140px;
height:
40px;
float:left;
padding:
10px;
margin:
10px;
background-color: #EEEEEE;
}
</style>
<script
src="jquery.js"></script>
</head>
<body>
<div
class="notMe">div class="notMe"</div>
<div class="myClass">div
class="myClass"</div>
<span class="myClass">span
class="myClass"</span>
<span
id="div">#666666</span>
<p >111111</p>
<p
class="myclass">111111</p>
<script>
$(".myClass").css("border","3px solid red");//类名选择
调用JavaScript的getElementsByClassName()
$("div").css("background","green");//标签选择 调用JavaScript的
getElementsByTagName()函数
$("#div").css("background","#666666");//id选择
调用JavaScript的document.getElementById();如果ID包含点号或冒号字符字符,你必须将
这些字符反斜杠转义.
$("p.myclass,#div").css("border-top","10px
dotted yellow");//id class
标签混合使用
</script>
</body>
</html>