jQuery Basics _ Must see Knowledge Points for Getting Started

  • 2021-07-01 06:27:08
  • OfStack

What is the causal relationship of jQuery events in 1 format:

$("button").click(function(){ })

[Official contact with jQuery]

(1) Writing steps of jQuery:
1. Introduce jQuery file;
2. Create a new pair of script tags to write jQuery;
3. Code separation by jQuery;
4. Write the code according to the principle of jQuery;

css Modification of jQuery

alert () pops up a warning box; Pop-up information can be written in parentheses as parameters;
css ()

1. Single attribute fetch, format css ("css attribute name to fetch")

2. Single attribute modification, format css ("Parameter 1", "Parameter 2")

Parameter 1: Represents the name of the css attribute to be modified;
Parameter 2: Represents the value to be modified;

3. Multi-attribute modification, format css ({attribute name: "value", attribute name: "value",...})
Note: The modification of css composite attribute; When encountering compound attributes, css attributes need to be written according to hump nomenclature;

"Base selector"

> Represents the only 1-level descendant element of the specified element selected;
Indicates that only 11 elements immediately following the specified element are selected
~ indicates that all elements following the specified element are selected;

All filter selectors in jQuery have one feature, which starts with a colon;

"Filter selector"

: not () excludes a 1 element or a 1 class element from the specified element
: eq () filters according to the specified index value (note that the index value in the program starts from 0)
: gt () filters all elements larger than the specified index value;
: lt () filters all elements that are less than the specified index value;
(Note; No matter whether it is greater than or less than, it does not include itself;)

"Filter selector"

There are 3 giant selectors in the screening selector, father and son;
Features: All filter selectors are a function situation, so it will not be written inside the selection symbol;
Parent: parent () selects the parent element of the current element;
Sub: children () selects a subset of the current element; Parameters can be passed again in parentheses for finer filtering;
Brother: sibling () selects all sibling elements of the current element; (Excluding oneself)

$(this) Note the use of the

The animation and events in jQuery follow a principle called queuing mechanism, that is to say, if a lot of animations are triggered at one time, the following animations will not automatically replace the previous ones, but will be queued straight for execution;

Solution: Use stop () function to empty the queue before executing animation;

"Controlling html Properties"

attr ("tag attribute name", "corresponding value")


Related articles: