The nature of jquery is still encapsulated JS, but the code is more concise, and do better
Using the jquery selector returns a JQuery object, which is essentially a DOM array, and the jquery object can invoke the JQuery method.
1 Basic Selector
1.1 ID Selector
jquery ==> $ (' #btnShow ');
JS ==> document.getElementById (' btnshow ');
1.2 Tag Selector
jquery ==> $ (' img ');
JS ==> document.getelementsbytagname (' img ');
Class 1.3 Selector
JS ==> document.getelementsbyclassname (' Test ');
2 Properties
2.1 Prop represents the original HTML property
2.2 attr denotes extended attributes (more commonly used)
2.3 Properties
2.3.1 Setting properties
$ (' a '). attr (' href ', ' http://www.baidu.com ');
2.3.2 Removing properties
$ (' a '). removeattr (' href ', ' http://www.baidu.com ');
2.3.3 Gets the value of the values property is more special
$ (' #btnShow '). Val ();
2.3.4 Setting the Value property is special
$ (' #btnShow '). Val (' Zhang San ');
3 Events
3.1 Way One bind (event type, processing function);
3.2 Mode two event types (processing functions); The event type is the same as in the DOM, and the on prefix is removed.
3.3 Bind a fixed-point click event, remove on, use parentheses
$ (' #btnShow '). Click (function () {
Alert (' anonymous function does parameter ');
alert (this.value);//this is a DOM object and cannot call the jquery method
});
3.4 Uninstallation Events
Unbind ();//Remove all event handlers
Unbind (' Clicke ');//Remove all event handlers
Step by Step -56-jquery Foundation