


The content of this article is about the use of hide() and show() in JQuery animation (code example). It has certain reference value. Friends in need can refer to it. I hope it will be useful to you. Helps.
hide() and show() methods can set animation effects. This article explains the effects of these two methods.
hide (parameter 1, parameter 2):
Parameter 1: time, in milliseconds, indicating the time it takes for the object to be hidden
Parameter 2: callback function, this function Fires after the object is hidden.
show(parameter 1, parameter 2):
Parameter 1: Same as above
Parameter 2: Same as above
Example:
Description of requirements: Click on a picture, the picture will be slowly hidden, and then deleted from the page. The latter picture will supplement the position of the previous picture.
The code is as follows:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Title</title> <style type="text/css"> img{ width: 100px; height: 80px; } #pics div{ float: left; margin: 2px; width: 100px; height: 80px; } </style> <script src="js/jquery-1.12.2.js" type="text/javascript" charset="utf-8"></script> <script> $(function(){ //獲取所有的圖片,并注冊點擊事件 $("#pics>div").click(function(){ $(this).hide(800,function(){ //回調(diào)函數(shù),清除當(dāng)前點擊的元素 $(this).remove();//方法移除當(dāng)前調(diào)用這個方法的元素---自殺 }); }); }); </script> </head> <body> <div id="pics"> <div><img src="images/01.jpg" ></div> <div><img src="images/02.jpg" ></div> <div><img src="images/03.jpg" ></div> <div><img src="images/04.jpg" ></div> <div><img src="images/05.jpg" ></div> </div> </body> </html>
Note:
$(this).remove();//方法移除當(dāng)前調(diào)用這個方法的元素---自殺
The above is the detailed content of JQuery animation hide() and show() usage explanation 1 (code example). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Java and JavaScript are different programming languages, each suitable for different application scenarios. Java is used for large enterprise and mobile application development, while JavaScript is mainly used for web page development.

JavaScriptcommentsareessentialformaintaining,reading,andguidingcodeexecution.1)Single-linecommentsareusedforquickexplanations.2)Multi-linecommentsexplaincomplexlogicorprovidedetaileddocumentation.3)Inlinecommentsclarifyspecificpartsofcode.Bestpractic

The following points should be noted when processing dates and time in JavaScript: 1. There are many ways to create Date objects. It is recommended to use ISO format strings to ensure compatibility; 2. Get and set time information can be obtained and set methods, and note that the month starts from 0; 3. Manually formatting dates requires strings, and third-party libraries can also be used; 4. It is recommended to use libraries that support time zones, such as Luxon. Mastering these key points can effectively avoid common mistakes.

PlacingtagsatthebottomofablogpostorwebpageservespracticalpurposesforSEO,userexperience,anddesign.1.IthelpswithSEObyallowingsearchenginestoaccesskeyword-relevanttagswithoutclutteringthemaincontent.2.Itimprovesuserexperiencebykeepingthefocusonthearticl

JavaScriptispreferredforwebdevelopment,whileJavaisbetterforlarge-scalebackendsystemsandAndroidapps.1)JavaScriptexcelsincreatinginteractivewebexperienceswithitsdynamicnatureandDOMmanipulation.2)Javaoffersstrongtypingandobject-orientedfeatures,idealfor

JavaScripthassevenfundamentaldatatypes:number,string,boolean,undefined,null,object,andsymbol.1)Numbersuseadouble-precisionformat,usefulforwidevaluerangesbutbecautiouswithfloating-pointarithmetic.2)Stringsareimmutable,useefficientconcatenationmethodsf

Event capture and bubble are two stages of event propagation in DOM. Capture is from the top layer to the target element, and bubble is from the target element to the top layer. 1. Event capture is implemented by setting the useCapture parameter of addEventListener to true; 2. Event bubble is the default behavior, useCapture is set to false or omitted; 3. Event propagation can be used to prevent event propagation; 4. Event bubbling supports event delegation to improve dynamic content processing efficiency; 5. Capture can be used to intercept events in advance, such as logging or error processing. Understanding these two phases helps to accurately control the timing and how JavaScript responds to user operations.

Java and JavaScript are different programming languages. 1.Java is a statically typed and compiled language, suitable for enterprise applications and large systems. 2. JavaScript is a dynamic type and interpreted language, mainly used for web interaction and front-end development.
