Home >Web Front-end >JS Tutorial >Learn about the use of fadeOut() method in jQuery
This article mainly introduces the usage of the fadeOut() method in jQuery, and analyzes the function, definition and specific usage techniques of the fadeOut() method in the form of examples. It has certain reference value. Friends in need can refer to it
The example in this article describes the usage of the fadeOut() method in jQuery. Share it with everyone for your reference. The specific analysis is as follows:
This method achieves the fade-out effect of all matching elements through changes in opacity, and optionally triggers a callback function after the animation is completed. .
Usage of fadeOut() method:
This method can specify the duration of the animation effect. For example:
The code is as follows:
$("p").fadeOut(5000)
The above code stipulates that the fade-out effect of p can be within 5000 milliseconds (5 completed within seconds).
This method can also trigger a callback function after the animation is completed. For example:
The code is as follows:
$("p").fadeOut(5000,function(){alert('Animation effect completed!')})
The above code can trigger the callback function after the animation is completed, so a prompt box will pop up.
Example code:
The code is as follows:
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"/> <meta name="author" content="http://www.jb51.net/" /> <title>fadeOut()函数-脚本之家</title> <style type="text/css"> p{ background :#060; width:300px; height:300px; color:red } </style> <script type="text/ javascript " src="mytest/jQuery/jquery-1.8.3.js"></script> <script type="text/javascript"> $( document ).ready(function(){ $("#up").click(function(){ $("p").fadeOut(5000,function(){alert('动画效果完成!')}); }) }) </script> </head> <body> <p></p> <button id="up">点击查看效果</button> </body> </html>
The above is the detailed content of Learn about the use of fadeOut() method in jQuery. For more information, please follow other related articles on the PHP Chinese website!