Basic jquery and basic jquery tutorials
I. Basic selector:
ID selector: $ ("# id name ")
For example: $ ("# div1" ).css ("width", "100px ");
CLASS selector: $ (". id name ")
Coordinate $ ("# id name, # id name ")
Descendant $ ("# id name ")
Ii. Filter Selector
First: $ (". id name: first ")
Last: $ (". id name: last ")
Any one: $ (". id name"). eq (index number) or $ (". id name: eq (Index Number )")
Greater than: $ (". id name: gt (Index Number )")
Less than: $ (". id name: lt (Index Number )")
Not equal to: $ (". id name: not (Index Number )")
Odd: $ (". id name: odd ")
3. Content Filtering
Even number: $ (". id name: even ")
Attribute name: $ (". id name [attribute name]")
Operation of attribute name: $ (". id name [attribute name]" ).css ("width", "100px ");
Content Filtering: $ (". id name: contains ('string ')")
Child element: $ (". id name: has ('child element '))
Event:
General events: Remove on
Composite event:
Hover: hover (function () {}, function (){});
: Toggle (function () {}, function (){}......);
Bubble event:
Five divs are nested in sequence
Effect:
Event: Click the pop-up id name
In this way, the smallest div is clicked, And the id names of all div
Solution: return false
DOM operation:
Operation attributes, methods, and styles
Attribute
First: click the button to hide txt1. Second, click the button to query the background color of txt1 and change the background color of Button 2.
Operation form elements:
Value: var d = $ ("selector"). val () Value: $ ("selector"). val ("value ")
Non-form elements:
Valid values: $ ("selector" ).html ("content"), $ ("selector"). text ("content ")
Value assignment: var s = $ ("selector" Contents .html ("content"), var s = $ ("selector"). text ()
Operation-related elements
1. Search
Parent level:
Add a parent () to the parent level ()
Select a parent level:. parents ("# id ")
Child level: children ()
Brother/level:
Brother: prev ()
Prevall (selector)
Younger brother: next ()
Nextall (selector)
Ii. Operations
New: $ ("HTML string ")
Add: appen (jquery object) Internal add
After (,...) added at the lower level
Before ("...") upper level
Remove:
Empty () clears all internal elements
Remove () remove an element
NOTE: If js is not written at the end, $ (document). ready (function () {write here}) must be added at the beginning });