JavaScript jQuery usage and reference order
Reference Order:
first lead the CSS and then lead JS
JS in the first cited jQuery, and then cited jabascript, and then lead their own JS
Usage:
JQuery needs to introduce a js file, and before all the js Code
1. Find the Label:
JS : document.getelement .... contains all the search codes Dom Object
JQuery :$ ( selector ); selector contains ID Selector,class selector jQuery Object
the following two sentences represent finding a label with ID AA and adding a classto this tag, with avalue of BB ;
Dom Object
document.getElementById (' AA '). SetAttribute (' class ', ' BB ');
JQuery Object
$ (' ddd '). attr (' class ', ' BB ');
2.jQuery objects and JS Object Conversions
jquery=="JS
is the class value, this sentence means that the class is BB of the element subscript 0 of the turn into Dom Object
$ ('. bb ') = ="$ ('. BB ') [0] | | $ ('. BB '). Get (0)
is an ID value, this sentence indicates that the element with the ID BB is turned into a Dom object
$ (' #bb ') = ="$ (' #bb ') [0] | | $ (' #bb '). Get (0)
manipulate The element labeled 0 in JQuery to manipulate the first few parentheses to write a few
$ ('. BB '). EQ (0);
JS = ="jQuery "
now there is a Dom object
var dom = document.getElementById (' ddd ');
direct the variable name to the Dom and turn the Dom object into a jQuery Object
$ (DOM)
3. operation Contents
Js:dom represents the JS Object
form : Dom.value
non-forms:dom.innethtml
jquery: $ represents a jQuery Object
form : $.val (); $.val (' modified value ');
non-forms : $.html (); $.html (' modified value '); $.text () has the same effect as HTML
4. Operation Properties:
JS:
Action Properties:
Dom.setattribute ( attribute name , attribute value );
Get Properties:
Dom.getattribute ( attribute name );
Jquery:
Action Properties:
$.attr ( attribute name, attribute value );
Get Properties:
$.attr ( attribute name )
when manipulating multiple properties:
$.ARRT ({ Property Name: Property value , property name : property value });
5. Operation Style
JS:
Action Style
Dom.style. style
Jquery:
Action Style
$.css(attribute name , attribute value );
$.css(attribute name );
when manipulating multiple properties:
$.css ({ Property Name: Property value , property name : property value });
6. Events
JS: Add Event
Dom. AddEventListener ();
JQuery: you can write an event directly after adding an incident , and what event to write
$.onclick (function () {
})
<inputtype= "checkbox"name= "1"><inputtype= "checkbox"name= "2"><inputtype= "checkbox"checked name= "3"><inputtype= "checkbox"name= "4"><Script> $('input[type= "checkbox"]:checked') </Script>Find Elements
jquery Basic Finishing!!