JQ中toggle替代方案

版权声明:本文为QQ帝国原创博客,非经本人同意,且勿转载。。 https://blog.csdn.net/QQ_Empire/article/details/83176836
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<style>
		.dian{width: 100px;height: 30px ;background: #000;color: #fff;}
		.bbb{width: 200px;height: 200px;background: green;}
		.jia{}
	</style>
	<body>
		<ul>
			<li class="dian">点击</li>		
		</ul>
		
		
		<div>
			<div class="bbb"></div>
			
		</div>
	</body>
	<script type="text/javascript" src="jquery-1.11.0.js" ></script>
	<script>
		
		var i=0;
        $(".dian").click(function() {
            if(i==0){
                 $(".bbb").hide(500);
                 i=1;
            }else  {
                 $(".bbb").show(500);
                 i=0;
            }

        });

			
	</script>
</html>

猜你喜欢

转载自blog.csdn.net/QQ_Empire/article/details/83176836