<JavaScript> Custom Animations

Source: Internet
Author: User

Tag: Har object default option ASC base hidden Order Input

The animate () method executes a custom animation of the CSS property set.

This method changes the element from one state to another through CSS styles. CSS property values are changed gradually so that you can create animation effects.

Only numeric values can create animations (such as "margin:30px"). String values cannot create animations (such as "background-color:red").

Example code:

<! DOCTYPE html>p {color:red;            } div{width:200px;            height:100px; Background-Color:yellow;        color:red; }    </style> <script src= ". /jquery/jquery-3.3.1.js "></script>Click to observe the animation effect:<select id= "Animation" > <option value= "1" > Animation 1</option> <option value= "2" > Animation 2</option> <option value= "3" > Animation 3</option> <option value= "4" > Animation 4</option></select><input id= " Exec "type=" button "value=" execution animation "><script type=" Text/javascript ">/*The animate () method allows us to create animations on the CSS properties of any numeric value.     * 2 syntax used, almost almost, the only necessary property is a set of CSS property key-value pairs.     * Note that there is a comma behind each CSS Property!!!! * * * * One or more of the CSS properties of the key-value pairs are composed of object objects.     It is important to note that all properties used for animation must be numeric!!!!! */    $("#exec"). Click (function() {        varv = $ ("#animation"). Val (); var$aaron = $ ("#aaron"); if(v = = "1") {            //the units of the values are PX by default$aaron. Animate ({//CSS properties are a set of braces that need to be expanded.width:300, Height:300            },3000,function() {alert (Finished)            }); } Else if(v = = "2") {            //100px on the basis of existing heights$aaron. Animate ({width:"+=100px", Height:"+=100px"            }); } Else if(v = = "3"{$aaron. Animate ({fontSize:"5em"            }, 2000,function() {alert ("Animation FontSize executed!");        }); } Else if(v = = "4") {            //switching heights with the toggle parameter$aaron. Animate ({//width: "Toggle",//Use this width to hide elementsBorderWidth: "6px"//Add Border            }); }    });</script></body>

<JavaScript> Custom Animations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.