Jquery中toggleClass的两种用法

css样式:

<style type="text/css">
.bgc{ background-color:#F00; color: #FFF}
</style>

Jquery代码:

第一种用法:

1.	<script type="text/javascript">
	$(function(){
		$("#child").mouseover(setColor).mouseout(setColor);
		function setColor(){
			$(this).toggleClass("bgc");
			}
	});	


第二种用法:

2.	<script type="text/javascript">
	$(function(){
		$("#child").bind("mouseover mouseout",function(){
			$(this).toggleClass("bgc");
			});
	});	
</script>


原文地址:https://www.cnblogs.com/riskyer/p/3290118.html