Detailed explanation of the effects of jQuery operations
jQuery Effect operations are divided into five categories: 1. Basic, 2. Slide, 3. Fade in and fade out, 4. Customized, 5. Settings. This article will explain this in detail. Has very good reference value. Let’s take a look with the editor below
The effect operations are divided into five categories: 1. Basic, 2. Slide, 3. Fade in and fade out, 4. Customized, 5. Settings
##show(), hide(), toggle()
The code is as follows:html code:
<p style="display: none">Hello</p> <input id="btn1" type="button" value="切换"/>
jQuery code:
$("p").show();
The P tag is now displayed. After executing this line of code, P is hidden
$("#btn1").click(function(){ $("p").toggle("show"); })Bind a click event to the
button
. When P is real, let it be hidden. If P is hidden, let it be displayed.
show(), displays hidden matching elements. hide(), hide the displayed elements. toggle() is used to bind two or more
event handlerfunctions to respond to the click event of the selected element in turn.
slideDown(), slideUp(), slideToggle()
The code is as follows:
html code:
<p></p> <input id="btn1" type="button" value="展开"/> <input id="btn2" type="button" value="收缩"/> <input id="btn3" type="button" value="切换"/>
jQuery code:
$("#btn1").click(function(){ $("p").slideDown(); }); 给id为btn1的按钮绑定click事件,当点击展开按钮的时候,p向下展开。 $("#btn2").click(function(){ $("p").slideUp(); }); 给id为btn2的按钮绑定click事件,当点击展开按钮的时候,p向上收缩。 $("#btn3").click(function(){ $("p").slideToggle(); });Bind the click event to the button with ID btn3. When p expands downward, it shrinks upward, and vice versa.
Note:
slideDown(), expand downward. Slide Up(), shrink upward. slide Toggle(), switches the visibility of all matching elements through height changes.
The effect is as follows:
#fadeIn(), fadeOut(), fadeTo(), fadeToggle()
The code is as follows:
html code:## <p></p>
<input id="btn1" type="button" value="淡入"/>
<input id="btn2" type="button" value="淡出"/>
<input id="btn3" type="button" value="切换"/>
<input id="btn4" type="button" value="设置透明度"/>
$("input").first().click(function(){
$("p").fadeIn(1000);
});
Use the selector to select the first input and bind a click event to it. p is hidden at first. It will be displayed slowly within one second to achieve the fade-in effect.
$("input").eq(1).click(function(){ $("p").stop().fadeOut(1000); //$("p").fadeOut(1000); });Use the selector to select the second input and bind a click event to it. p is now displayed, and it will slowly hide within one second. , to achieve the fade-out effect.
$("input").eq(2).click(function(){ $("p").stop().fadeToggle(1000); })Use the selector to select the third input, bind a click event to it, when p is displayed, let it fade out, and vice versa, when p is hidden time, let it fade in.
$("input").eq(3).click(function(){ $("p").stop().fadeTo(1000,0.5); })Use the selector to select the fourth input, bind a click event to it, and set the fade-in (fade-out) time and transparency.
Note:
fadeIn(), achieves the fade-in effect of all matching elements through changes in opacity.
fadeOut(), which achieves the fade-out effect of all matching elements through changes in opacity. fadeTo(), gradually adjusts the opacity of all matching elements to the specified opacity. fadeToggle(), switches the fade-in and fade-out effects of all matching elements through changes in opacity.
The effect is as follows:
##animate(), stop(), delay()
css code:
##
p{ width:100px; height:100px; background:red; }html Code:
<p>ST宋泽</p> <input id="btn1" type="button" value="显示效果"/> <input id="btn2" type="button" value="停止动画"/>jQuery Code:
$("#btn1").click(function(){ $("p").delay(2000).animate({ "width":"300px", "height":"300px", "font-size":"4em" },5000,function(){ console.log("动画完成") }) });
给id为btn1的按钮绑定click事件,当点击按钮的时候,延迟两秒钟,p的width,height,font-size会
逐渐变成设置的这些值,两秒之后打印 “动画完成”。
$("#btn2").click(function(){ $("p").stop(); })
给id为btn2的按钮绑定click事件,当p正在做动画的时候,点击按钮,动画会停止。
注释:animate(),用于创建自定义动画的函数。
stop(),停止所有在指定元素上正在运行的动画。
delay(),设置一个延时来推迟执行队列中之后的项目。
效果如下:
jQuery.fx.off,jQuery.fx.interval
jQuery.fx.off,关闭页面上所有的动画。
jQuery.fx.interval,设置动画的显示帧速。
The above is the detailed content of Detailed explanation of the effects of jQuery operations. For more information, please follow other related articles on the PHP Chinese website!

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.


Hot AI Tools

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

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

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver Mac version
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Atom editor mac version download
The most popular open source editor