日期:2014-05-16 浏览次数:20793 次
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery 点击变色</title>
</head>
<style type="text/css">
#t1,#t2,#t3,#t4{
height:30px;
width:50px;
background-color:#33FFFF;
float:left;
margin-left:50px;
text-align:center;
}
.active{background-color:#FC5A0A!important;}
</style>
<script type="text/javascript" src="http://www.codefans.net/ajaxjs/jquery1.3.2.js"></script>
<script type="text/javascript">
jQuery(function(){
var list = jQuery('#t1, #t2, #t3, #t4');
list.click(function(){
list.removeClass('active');
jQuery(this).addClass('active');
});
});
</script>
<body>
<div id="t1"><a href="">点击</a></div>
<div id="t2"><a href="">点击</a></div>
<div id="t3"><a href="#">点击</a></div>
<div id="t4"><a href="#">点击</a></div>
</body>
</html>