设置div元素渐隐效果代码实例
分类:实例代码
以动画平滑的动画方式实现元素的隐藏效果,比瞬间隐藏的方式更为人性化。
下面就是一段使用jQuery实现的此效果,代码如下:
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.pipipi.net/" /> <title>前端教程网</title> <style> #one{ width:80px; height:80px; background-color:red; } #two{ width:80px; height:80px; background-color:green; } #three{ width:80px; height:80px; background-color:blue; } </style> <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script> <script> $(document).ready(function(){ $("#bt").click(function(){ $("#one").fadeOut(); $("#two").fadeOut("slow"); $("#three").fadeOut(3000); }); }); </script> </head> <body> <input type="button" id="bt" value="查看效果"/> <br> <div id="one"></div><br> <div id="two"></div><br> <div id="three"></div> </body> </html>
一线大厂高级前端编写,前端初中阶面试题,帮助初学者应聘,需要联系微信:javadudu