赞
踩
Demo:
<!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>Jquery之淡入淡出效果</title> <style> .box{ width:200px; height:200px; background-color:pink; margin-top: 100px; } </style> <script src="../../js/jquery.min.js"></script> <script> $(function(){ $('#fadeIn').on('click',function(){ //实现淡入效果 // $('.box').fadeIn(); $('.box').fadeIn(3000,function(){ alert('fade in!'); }); }); $('#fadeout').on('click',function(){ //实现淡出效果 // $('.box').fadeOut(); $('.box').fadeOut(3000,function(){ alert('fade out!'); }); }); $('#switchfadeInOut').on('click',function(){ //实现淡入淡出切换效果 // $('.box').fadeToggle(); $('.box').fadeToggle(3000,function(){ alert('fade toggle!'); }); }); $('#adjustopacity').on('click',function(){ //修改元素的透明度: //faceTo(speed,opacity,[callback]) //必须指定速度和不透明度 $('.box').fadeTo(300,0.5); }); }); </script> </head> <body> <button id="fadeIn">淡入</button> <button id="fadeout">淡出</button> <button id="switchfadeInOut">淡入淡出切换</button> <button id="adjustopacity">修改透明度</button> <div class="box"></div> </body> </html>
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。