<body>
<div></div>
<div id="b"></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
<style>
div{height:100px;width:100px;border:1px solid #ccc;margin-bottom:10px; background-color:white; cursor:pointer;}
</style>
<script type="text/javascript">
$(function(){//记得将事件放在function里面。
$("div").click(function(){
if($(this).is("#b")){$(this).css("backgroundColor","red");}
else{$(this).css("backgroundColor","green");}
})
})
/*$(function(){
$("#b").click(function(){
$("#b").css("backgroundColor","#f60")
})
})*/
</script>