An article to help you understand jQuery animation

An article to help you understand jQuery animation
jQuery provides some default animations to control the display and hiding of elements: show() hide()
	Control the transparency of an element fadeIn() fadeOut()
	Control the height of an element slideUp() slideDown()
	Custom animation animate()

1. Control the display and hiding of elements show() hide()

grammar:

 $("selector").show([speed],[callback]);

Reference description:

Parameter 1 : speed, optional, for example: 1000 milliseconds, 1 second, fast, slow, normal

Parameter 2 : callback function, optional function to be executed after the show or hide function is executed

$(function () {
			$(".nav-ul li").on({"mouseover":function () {
					$(this).css("background","pink")
				},"mouseout":function () {
					$(this).css("background","#ff2832")
				}});
			$(".menu-btn").hover(function () {
				$(this).next().show("fast")
			},function () {
				$(this).next().hide("slow")
			})
		})

2. Control the transparency of elements fadeIn() fadeOut()

grammar:

    $("selector").fadeIn([speed],[callback]);
    $("selector").fadeOut([speed],[callback]);

Reference description:

Parameter 1 : speed, optional, default is 0, for example: 1000 milliseconds, etc., 1 second fast slow normal

Parameter 2 : callback function, optional. The function to be executed after fadeIn or fadeOut is executed.

$(function () {
		$("input[name='fadein_btn']").click(function () {
			$("img:eq(0)").fadeIn(500,function () {
				alert("fade in successfully")
			})
		})
		$("input[name='fadeout_btn']").click(function () {
			$("img:eq(0)").fadeOut(1000,function () {
				alert("fade out successfully")
			})
		})
	})

3: Control the height of the element slideUp() slideDown()

slideDown() makes the element gradually extend and display

slideUp() makes the element gradually shorten until it is hidden

grammar:

    $("selector").slideUp([speed],[callback]);
    $("selector").slideDown([speed],[callback]);

Reference description:

Parameter 1: speed, optional, default is 0, for example: 1000 milliseconds, etc., 1 second fast slow normal

Parameter 2: callback function, optional. The function to be executed after slideUp or slideDown is executed.

Summarize

This article ends here. I hope it can be helpful to you. I also hope that you can pay more attention to more content on 123WORDPRESS.COM!

You may also be interested in:
  • jQuery implements ad display and hide animation
  • jQuery animation operation complete example analysis
  • JQuery animate animation application example
  • Detailed explanation of JQuery basic animation operations
  • [jQuery] Detailed explanation of events and animations

<<:  Use CSS3 background control properties + color transition to achieve gradient effect

>>:  Have you really learned MySQL connection query?

Recommend

Zabbix monitoring docker application configuration

The application of containers is becoming more an...

An example of how to implement an adaptive square using CSS

The traditional method is to write a square in a ...

How to install git on linux

1. Introduction Git is a free, open source distri...

How does MySQL ensure data integrity?

The importance of data consistency and integrity ...

Some lesser-known sorting methods in MySQL

Preface ORDER BY 字段名升序/降序, I believe that everyon...

Introduction to JavaScript Number and Math Objects

Table of contents 1. Number in JavaScript 2. Math...

How to implement Echats chart large screen adaptation

Table of contents describe accomplish The project...

How does MySQL ensure master-slave consistency?

Table of contents The basic principle of MySQL ma...

vite2.x implements on-demand loading of ant-design-vue@next components

1. Use version vite:2.0 ant-design-vue: 2.0.0-rc....

Complete steps to install MySQL 5.5 on CentOS

Table of contents 1. Preparation before installat...

Detailed explanation of docker command to backup linux system

tar backup system sudo tar cvpzf backup.tgz --exc...

HTML basic summary recommendation (text format)

HTML text formatting tags 標簽 描述 <b> 定義粗體文本 ...

Minimalistic website design examples

Web Application Class 1. DownForEveryoneOrJustMe ...