jquery is a JavaScript library that gets a complete set of defined methods by encapsulating native JavaScript functions. In a jquery program, both the selection of page elements and the built-in function functions are the starting point of the dollar sign "$". And this "$" is the most important and exclusive object of jquery: jquery object. In itself is the abbreviated form of the jquery object:
$ (function// execute an anonymous function equivalent to jquery (function () {});
And the JQuery method returns the JQuery object, so you can use the Concatenating method:
// concatenating
and "#box" is the way to select elements based on the ID
Notes
Code annotations and JavaScript are consistent in jquery, with two of the most common comments: single-line use of "/...", multiline use "/* ... * *"
Load Code mode
In JavaScript, we wait for the page body to wait for loading using the window.onload (function () {}) method, while jquery uses $ (document). Ready (function () {}) The shorthand method is $ (function () {});
get native DOM elements
In JavaScript we are using:
// get the DOM element of Id=box
In jquery you can use, after all, the encapsulation of JavaScript, the original thing can not be used too much to say, but jquery want to reach the original DOM object could be like this:
Alert ($ (' #box '). Get (0));
dealing with conflicts between jquery and other libraries
For example, if you have a library that uses "$", it will conflict with jquery. Outcome measures:
1. You can put this library behind the jquery Library, "$" belongs to this library, and jquery can use jquery objects instead of "$", or create a new character for JQuery to use:
var // Create a $$ jquery object $ (function () {alert ($$ (/// This is JQuery's $$});
2. If you feel that the sequencing of the processing library references is cumbersome, you can use Jquery.noconflict () and create a new character to combine the methods used by JQuery:
// Remove the $ character ownership var $$ = jquery;$ (function () {alert ($$ (' #box '). width ());});
jquery Notes-Basic knowledge