filtering, binding and animation

Source: Internet
Author: User

First, basic filter

Grammar Describe return value
: First Select the first element Single element
: Last Select the last Element Single element
: Not (selector) Select to remove all elements that match the given selector Collection elements
: Even Select all elements with an even number (index starting from 0) Collection elements
: Odd Selects all elements with an odd index (index starting from 0) Single element
: EQ (Index) Select an element with index equal to index Collection elements
: GT Select an element with an index greater than index Collection elements
: LT Select an element with index less than index Collection elements
: Header Select all heading elements, such as H1~h6 Collection elements
: Focus Select the element that currently takes focus Collection elements

Second, the visibility of filter selector

Selector Selector Describe return value
: Visible Select all visible elements Collection elements
: Hidden Select all hidden elements Collection elements

Iii. binding events and removing events

Bind event method Bind () and Remove event method unbind () when one or more events are bound or removed for a matching element at once

Eg: Achieve light bar effect

        Bind event bind  Unbind        $ (function () {            $ ("li"). Bind ("MouseOver", function () {               $ (this). CSS ("Background", "Pink");            }). Bind ("Mouseout", function () {                $ (this). CSS ("Background", "");           });         Remove Event            $ ("Li"). Unbind ("MouseOver mouseout");        })

Added: Binding removal events can also be implemented using on off, live die, delegate undelegate scenarios

Iv. animations in jquery

1. Simple animation

① control element Display and hide

Show (), Hide ()

② changing element transparency

FadeIn (), FadeOut ()

③ changing the height of the element

Slideup () and Slidedown ()

Eg: Achieve fade effect

    <title></title>    <script src= "js/jquery-1.11.1.js" ></script>    <script type= " Text/javascript ">        $ (function () {            $ (" #btnIn "). Click (function () {                $ (" img "). Slidedown (" slow ");            });            $ ("#btnOut"). Click (function () {                $ ("img"). Slideup ("slow");            })    </script>

2. Complex animation <animate>

  <title></title>    <style type= "text/css" >        div {        height:20px;        border:1px solid red;        }    </style>    <script src= "js/jquery-1.11.1.js" ></script>    <script src= "js/ Jquery-migrate-1.2.0.js "></script>    <script type=" Text/javascript ">        $ (function () {            $ ("[Type=button]"). Click (function () {                $ ("div"). Animate ({                    width: "70%",                    Height: "300%",                    Borderwidth:10                                    }). Animate ({                    fontSize: "50px"                }, {queue:false,duration:5000})            })    </script>

filtering, binding and animation

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.