jQuery achieves fade-in and fade-out effects

jQuery achieves fade-in and fade-out effects

Before using jQuery to complete the fade-in and fade-out effect, let's first get to know some codes:

  • fadeIn([ speed , [easing] , [fn] ]), parameters are optional
  • fadeOut([ speed , [easing] , [fn] ]), parameters are optional
  • Fade in and out switch fadeToggle([ speed , [easing] , [fn] ]), parameters can be omitted
  • Modify the transparency fadeTo([ [speed] , opacity , [easing] , [fn] ]). Note that the speed and transparency must be written here.

in

  • speed is speed
  • Easing is the transition effect
  • fn is the callback function

Then let's put the above code into the overall code to see the effect

The complete code is as follows

<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <title>Wellfancy</title>
    <style>
        div {
   margin: 10px;
   padding: 10px;
   width: 100px;
            display: none;
        }
    </style>
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
</head>
 
<body>
    <button>Fade-in effect</button>
    <button>Fade out effect</button>
    <button>Fade in and out switch</button>
    <button>Modify transparency</button>
    <div>
  <img src="images/1.jpg" style="width: 280px;">
 </div>
    <script>
        $(function() {
            $("button").eq(0).click(function() {
                $("div").fadeIn(1000);
            })
            $("button").eq(1).click(function() {
                $("div").fadeOut(1000);
 
            })
            $("button").eq(2).click(function() {
                $("div").fadeToggle(1000);
 
            });
            $("button").eq(3).click(function() {
                $("div").fadeTo(1000, 0.5);
 
            });
 
        });
    </script>
</body>
 
</html>

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Native js and jquery to achieve the fade-in and fade-out effect of image carousel
  • Examples of fade-in and slide-out effects implemented with jQuery
  • Simple implementation of jQuery fade-in and fade-out effect
  • jQuery implements universal version of mouse fade-in and fade-out effect
  • jQuery fade in and out, expand and shrink menu implementation code
  • Text fade-in and fade-out effect based on jQuery
  • Implementing fade-in and fade-out effect carousel based on jQuery
  • Basic practice of fade-in and fade-out special effects based on Jquery
  • jQuery news broadcast scrolling and fade-in and fade-out effect example
  • jQuery fades elements in and out to make the effect more vivid

<<:  MySQL 8.0.18 stable version released! Hash Join is here as expected

>>:  Detailed tutorial on migrating the home directory to a new partition under Ubuntu

Recommend

Mysql timeline data to obtain the first three data of the same day

Create table data CREATE TABLE `praise_info` ( `i...

Vue implements the function of calling the mobile phone camera and album

This article shares the specific code of Vue to a...

MySQL 5.7.11 zip installation and configuration method graphic tutorial

1. Download the MySQL 5.7.11 zip installation pac...

IE6 BUG and fix is ​​a preventive strategy

Original article: Ultimate IE6 Cheatsheet: How To...

Summary of CSS gradient effects (linear-gradient and radial-gradient)

Linear-gradient background-image: linear-gradient...

Example code for CSS to achieve horizontal lines on both sides of the text

This article introduces the sample code of CSS to...

Implementation example of Docker rocketmq deployment

Table of contents Preparation Deployment process ...

How to create scheduled tasks using crond tool in Linux

Preface Crond is a scheduled execution tool under...

Implementing access control and connection restriction based on Nginx

Preface Nginx 's built-in module supports lim...

W3C Tutorial (13): W3C WSDL Activities

Web Services are concerned with application-to-ap...

Free tool to verify that HTML, CSS and RSS feeds are correct

One trick for dealing with this type of error is t...

Use Firebug tool to debug the page on iPad

How to debug a page on iPad? When using iOS 5, you...

In-depth understanding of Linux load balancing LVS

Table of contents 1. LVS load balancing 2. Basic ...