日期:2014-05-16 浏览次数:20358 次
jQuery(function($){
$('a').toggle(function(){
alert('a');
$(this).removeClass('b').addClass('a');
},function(){
alert('b');
$(this).removeClass('a').addClass('b');
});
});
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://img.renzhe.com/static/js/jquery-1.8.3.min.js"></script>
<title>无标题文档</title>
<style type="text/css">
a{text-decoration:none;color:#f00}
.b{color:#000}
</style>
</head>
<body>
<a href="javascript:;" >this is anchor</a>
<script type="text/javascript">
jQuery(function($){
$('a').click(function(){
$(this).toggleClass('b');
});
});
</script>
</body>
</html>