Before learning jquery you need to have some basic knowledge of the following
The basic syntax of jQuery
$ (selector). Action ()
- $ compliant Definition This is a jquery statement
- (selector) is used to select an HTML element whose syntax is the same as the selector syntax of a CSS.
- Action () defines the method that operates the HTML element.
Like what:
$ (this). Hide () – hides the current element.
$ ("P"). Hide () – hides so <p> elements.
$ (". Test"). Hide ()-hides the element that is the class name test.
$ ("#test"). Hide ()-hides the element with ID test.
Document Ready Events
Almost all jquery has the following code:
$ (document). Ready (function () {
This is the document ready event handler to prevent jquery from executing before the page is loaded. This avoids the following similar situations:
Trying to hide an element that has not yet been created
Trying to get the size of a picture that has not been loaded
This method can also be used in the following simplified way:
$ (function () {
You can choose the way you like, but you usually use $ (document). Ready (function () {To facilitate the reading of the code.