JQuery useful built-in Functions Summary

Source: Internet
Author: User

1. CSS ()---Get or set CSS properties

Kinds of Syntex:

I. $ (' #foo '). CSS (' background ', ' #fff000 ', ' width ', ' 100px ');

Ii. $ (' #foo '). CSS ({background: ' #fff000 ',}); Original CSS Syntex

2. Text ()---Get or set the value of an element

$ (' #foo '). Text (' new text ');

3. Clone ()---Copy an element

$ (' #foo '). Clone ();

4. AppendTo (), append ()---Move an element to/be appended by an element (also changes the inheritance relationship BETW Een objects)

$ (' #foo '). AppendTo ($ (' #bar ')); is the same as

$ (' #bar '). Append ($ (' #foo '));

5. InsertAfter (), insertbefore (), etc---for all kinds of insertion

6. EQ ()/get ()---used as filter to select a element in the selection (as JQuery object/dom element)

$ (' #foo '). EQ (1). Text (' changed '); Change the text of the second element of a JQuery object ' #foo '

$ (' #foo '). Get (1); Get the second element of ' #foo ' as a DOM element

7. attr ()---Get or add an Attribute of an element

$ (' #foo '). attr (' Disable ', ' str '); Ignore the second input parameter ' str ' for Get function, otherwise for adding

8. REMOVEATTR ()---Remove an Attribute to an element

$ (' #foo '). Removeattr (' checked '); Uncheck the check box

$ (' #foo '). Removeattr (' readonly '); Set the input field to be read-only

9. Empty ()---Remove all children of a object

$ (' #foo '). empty ();

SetTimeout (function, int millisecond)---call a function with delay

SetTimeout (function () {alert (' time\ ' s up! ')}, 1000); wait for 1s before executing the function

FIND ()---selects all decsendents with conditions

$ (' #foo '). Find ('. Child '); Selects all children of ' #foo ' which has attribute [class = ' child ']

Size (), Length---Returns an integer of the number of elements

These the same use, except if count the length of string or array, only the length is available.

Animate (CSS, int millisecond)---display CSS changes by animation

$ (' #foo '). Animate ({width:100px, margin:120px}, 1000); The time defines the period of time that the animation uses

For all CSS properties The can be animated, view "Http://www.jb51.net/w3school/jquery/prop_length.htm"

Filter ()---Selects elements (not the children of whom, which are different from find ()) with conditions

$ (' #foo '). Filter (': odd '); Selects all elements of ' #foo ' with odd number of index

$ (' #foo '). Filter ('. Peer '); Selects all elements of ' #foo ' with attribute [class = ' peer ']

HTML ()---Get or set the InnerHTML of an element

$ (' P '). html (' Yes, you are! ');

Effect: <p>i am an inner html!<\p> ====> <p>yes, you are!<\p>//This doesn ' t change the H TML file itself, but only changes the display

Replace ()---Replace text in string objects

Stringobject.replace (/string to IS replaced/, "string to replace");

For detailed syntex of parameter of replace (), view http://www.w3school.com.cn/jsref/jsref_replace.asp

Children (), find (), parent (), parents ()

Eg: $ (' #foo '). Children ();

Children ()/parent () only selects the direct children/parent of ' #foo '

Find ()/parents () selects all descendant/ancestor elements of ' #foo '

---Select all elements with exception

$ (' #foo '). Children (). Not (". Bad")//Select all children of ' #foo ' except ones with attribute [class = ' bad ']

Remove ()---remove an element

$ (' #foo '). Remove ()//remove ' #foo '

JQuery useful built-in Functions Summary

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.