jquery Basic Animation effect

Source: Internet
Author: User

jquery Basic animation effect 1, show ()

The Hide () test case that is used to display the corresponding page element:

<p title="标题">测试</p><ul style="display: none">    <li title=‘苹果‘>苹果</li>    <li title=‘橘子‘>橘子</li>    <li title=‘菠萝‘>菠萝</li></ul>点击显示$(‘p‘).bind("click",function(){    $("ul").show();})点击切换效果$(‘p‘).toggle(function(){    $("ul").show();},function(){    $("ul").hide()})
Note: It is possible to add parameters in this

Speed: A string of three predetermined speeds ("slow", "normal", or "fast") or a millisecond value that represents the duration of the animation (for example: 1000)

Note the use of toggle () here
$(‘#test‘).click(function(){    $("ul").toggle();})————————————————slideDown$(‘p‘).toggle(function(){    $("ul").slideUp()},function(){    $("ul").slideDown();})
Note here that the This keyword, yesterday we have tested can not be used, because this is a JS thing, but can not be converted to jquery things

Demo Code:

$(‘#test‘).toggle(function(){    $(this).next().slideUp() ----注意这里和上边的写法不同之处},function(){    $(this).next().slideDown();})注意的和之前的隐藏显示一样,这里也有简化版$(‘#test‘).click(function(){    $("ul").slideToggle()})——————————————fadeIn    fadeOut---淡入淡出效果$(‘#test‘).toggle(function(){    $(this).next().fadeOut();},function(){    $(this).next().fadeIn();})
Note: Look at the API here also has its own concise wording, the use of a lot of attention to animate ()

--feel dissatisfied with the previous animation, okay, let's see here, custom animation effects

Custom Mobile Cases:

<div id="test"></div>   #test{            position: absolute;            width: 100px;            height: 100px;            border: 1px solid red;            background-color: gray;        }$(‘#test‘).click(function(){    $(this).animate({left:"500px"},3000)})
Note: Here you can add multiple conditions to the
$(‘#test‘).click(function(){    $(this).animate({left:"200px",height:"200px"},3000)})

Case 2:

<button id="left">?</button> <button id="right">?</button><div id="test"></div>$(‘#left‘).click(function(){    $("#test").animate({left:"-500px"},3000)})$(‘#right‘).click(function(){    $("#test").animate({left:"500px"},3000)})

jquery Basic Animation effect

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.