The example in this article describes how to implement the jquery fade-in and fade-out effect. Share it with everyone for your reference, the details are as follows:
There were some misunderstandings before, thinking that fading in and out means deleting the element, but in fact it just hides and displays the element.
The specific code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh" dir="ltr"> <head> <mce:script type="text/javascript" src="jquery-1.4.4.min.js" mce_src="jquery-1.4.4.min.js"></mce:script> <title>Example | xHTML1.0</title> </head> <body> <button id="click">click</button> <ul id="ul"> <li>#</li> <li>@</li> <li>$</li> </ul> <mce:script type="text/javascript"><!-- $(function () { var _num = 1; $("#click").click(function () { var _ul = $("#ul"); var _li = $("#ul li"); var _len = _li.length; var _str = "<li style="display:none" mce_style="display:none">" + _num + "</li>"; _li.eq(_len-1).fadeOut('slow',function () { $(this).remove(); }); ++_num; $(_str).prependTo(_ul).fadeIn('slow'); }); }); // --></mce:script> </body> </html>
Readers who are interested in more content related to jQuery special effects can check out the special topic of this site: "Summary of common classic special effects in jQuery"
I hope this article will be helpful to everyone in jQuery programming.