I. Introduction of jquery
jquery is a lightweight, multi-browser-compatible JavaScript library. Making it easier for users to work with HTML Document, Events, animate, and facilitate Ajax interaction can greatly simplify JavaScript programming. Its purpose is: "Write less, does more."
1. jquery Object
The jquery object is the object that is generated after wrapping the DOM object through jquery. jquery objects are unique to jquery. If an object is a jquery object, then it can use the method in jquery: For example, $ ("#i1"). html ().
$ ("#i1"). html () means to get the HTML code of an element with an ID value of I1, where HTML () is the method in jquery, which is equivalent to the DOM: document.getElementById ("I1"). InnerHTML. Although the jquery object is wrapping the DOM object, the jquery object cannot use any of the DOM's methods, nor does the DOM use any of the methods in jquery.
2. jquery syntax
The basic syntax is as follows:
$ (selector). Action ()
As with the next convention, when declaring a jquery object variable, add the $ symbol to the variable name, as in the following example:
var $variable =jquery Object var variable = dom Object $variable[0] //jquery object to DOM object
Second, selector
1. Basic Selector
ID Selector: $ ( "#id值") class selector: $ ( ". C1") for all element selectors: $ ( "*") Tag name selector: $ (" div") Combo selector: $ ("#i1, P")
2. Level Selector
The following x and Y can be any selector:
Descendant selector: $ ("x space y")---All descendants of X Y (descendants) son selector: $ ("x > Y") all sons of---x Y (son) adjoining selector: $ ("x +y")--- Find all the Y brother selectors that are immediately behind X: $ ("x ~y")---x after all the brothers Y
3. Attribute Selector
Note: double quotes with single quotes
[Attribute] with attribute [Attribute=value] //attribute equals [Attribute!=value] //Attribute Unequal instance: $ ("input[type= ' checkbox ']"); Take the input label of the checkbox type $ ("input[type!= ' text ']"); Take the input label that is not of type text
4. Basic Filter
The following basic filter is mainly used in the selector to further filter the selector, described as follows:
: First//Number one: EQ (index) //index equals the element that is indexed: last//FINAL: Even //match all elements with an even number of index values, starting from 0 count: Odd // Matches all elements with an odd index value starting from 0: GT (Index) //Match all elements greater than the given index value: LT (index) //matches all elements less than the given index value: not (selector) // Removes all elements that match a given selector: has (selector) //matches the element that contains the element that the selector matches
Some examples are as follows:
5. Form Selector
Python's introduction to learning _day58_ front-end Basics 1