<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
img {
width: 200px;
height: 200px;
position: absolute;
left: 0;
bottom: 0;
display: none;
}
</style>
</head>
<body>
<button>显示</button>
<button>隐藏</button>
<button>切换</button>
<button>淡入到</button>
<br>
<img src="1.jpeg"></img>
<script src="./jquery-1.12.1.min.js"></script>
<script>
// 点击显示按钮 图片显示
$('button:eq(0)').on('click',function(){
$('img').fadeIn(1000);
})
// 点击隐藏按钮 图片隐藏
$('button:eq(1)').on('click',function(){
$('img').fadeOut(1000);
})
$('button:eq(2)').on('click',function(){
$('img').fadeToggle(1000);
// $('img').toggle(1000);
})
//将透明度切换为0.3
$('button:eq(3)').on('click',function(){
$('img').fadeTo(1000,0.3)
})
</script>
</body>
</html>
网友评论