49 jQuery-使用show()与hide()方法动画显示和隐藏图片

版权声明:本文为大都督作者的原创文章,未经 大都督 允许也可以转载,但请注明出处,谢谢! 共勉! https://blog.csdn.net/qq_37335220/article/details/85632414

1.效果图

在这里插入图片描述

2.HTML代码

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <title>49 jQuery-使用show()与hide()方法动画显示和隐藏图片</title>
      <style type="text/css">
        body{font-size:13px}
		img{display: none;cursor: pointer;width: 60px;height: 60px;}
	  </style>
</head>
<body>
 	  <a style="cursor: pointer;">显示</a>
      <img src="../img/pig.jpg" />
              
<script src="../jquery.min.js"></script>
<script type="text/javascript">
	$(function(){
		//显示链接点击事件
		$("a").click(function(){
			//显示完成时执行的函数
			$("img").show(3000, function(){
				$(this).css("border", "solid 1px #ccc");
			})
			$(this).hide(3000);
		})
		//显示图片的点击事件
		$("img").click(function(){
			//动画效果隐藏
			$(this).hide(3000);
			$("a").show(3000);
		})
	})
</script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_37335220/article/details/85632414
49