jquery Basic Finishing!!

Source: Internet
Author: User

  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!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.