jQuery is a JavaScript library, jQuery is that the benefits of writing less to do more, jQuery features include HTML elements selection and operation, css operation, bind event function, JavaScript special effects and animation, html dom traversal and modification, ajax method.
Using jQuery process must first download the jQuery files, including compressed version of jQuery and uncompressed versions, versions are available for the development of uncompressed, readable code. jQuery is a Javascript file, you need to quote him with script tags.
jQuery chain can operate, also called chain method. For example, $ ( " # p1 " ) . CSS ( " Color " , " Red " ) . SlideUp ( 2000 ) . SlideDown ( 2000 ) ;
Methods commonly used base
1. Selector
Most of usage and usage of JavaScript the same, different wording
Tag selector: $ ( "p") select all elements p tags
id selector: $ ( "# id") select id id named element
$ ( ". Classname") class selector $ ( "[href]") element selector and the like.
Reference blog jQuery knowledge consolidation have mind map.
2.jquery binding events common method $ ( "p"). Click (funciton () {} function body)
3. Effect:
Show Hidden: But setting function and linear motion
$ ( " The p- " ) . Hide ( ) ; Hide
$ ( " The p- " ) . Show ( ) ; display
$ ( " The p- " ) . Toggle ( ) ; hidden time display, time display hidden
fade in and fade out
fadeIn () fade hidden elements
fadeout () fade visible elements
fade Toggle () method will fade in fade out fade in fade out
fadeTo () to set the opacity gradient $ ( " # DIV1 " ) . fadeTo ( " SLOW " , 0.15 ) ;
slide
slideDown ( ) ; slide down slideUp ( ) ; s slide upward lideToggle ( ) ; turn slidably
Animation
Animate () Create Animation can operate a plurality of height opacity properties and the like may be used relative value "+ ="
Stop the animation stop ()
4.HTML method
text () sets or returns the text content of the selected element
HTML () sets or returns the content of the element selected element
Val () Gets or sets the value of the input value
attr () Gets the value of the attribute
append () Inserts (back inside the selected element) in the end of the selected element
The prepend () is inserted at the beginning of the content of the selected element (on the inside front of the selected element)
after () is inserted after the selected element content (hereinafter, outside of the selected element)
before () before being inserted into the selected element content (on the outside front of the selected element)
remove () and delete elements selected content
empty () to delete the selected element in all child elements
addClass() 添加class name
removeClass () to delete one or more elements selected from the class
css () provided css style pattern disposed inside with css ""
() Size height () Set the selected element width
5. traversal
parent ( ) ; return all of the parent element of the element
$ ( " Span " ). ParentsUntil ( " div " ) ; return all ancestor elements interposed between the <span> and <div> elements
children () Returns all direct child elements of the element
find ( "span") returns all descendants of all the elements span inside
SIBLINGS ( ) ; return all compatriots elements of the selected element.
Next ( ) ; fellow returns the next element of the selected element.
nextAll ( ) ; return all of the following selected elements siblings
nextUntil () returns all sibling elements between two elements $ ( " h2 " ) . nextUntil ( " H6 " ) ; return <h2> elements between compatriots and all the elements <h6>:
first () returns the first element
last () returns the first element of the countdown
EQ () returns the corresponding element $ ( " P " ) . EQ ( 1 ) ; Returns the index number of the element, i.e., 1 second (as is zero)
filter () to develop a standard, does not meet this standard elements will be deleted, and then returns the matching element.
not () returns non-compliant elements