Use jQuery to operate DOM and jquery to operate dom

Source: Internet
Author: User

Use jQuery to operate DOM and jquery to operate dom

I. DOM operations are divided into three categories

1. DOM Core

DOM Core is not a specialized product of Javascript. It can be used by any programming language that supports DOM. Its purpose is not limited to processing a document written in a markup language.

2. HTML-DOM

It appears earlier than DOM Core and provides more concise markup to describe the element attributes of various HTML-DOM

3. CSS-DOM

CSS-DOM loss of CSS operations, in JavaScript, as long as the role is to get and set the style Object Attributes

Ii. style operations

1. directly set the style Value

Css (name, value) // sets a single attribute

Css ({name: value, name: value, name: value...}) // set multiple attributes

2. append and remove styles

AddClass (class) // append Style

RemoveClass (class) // remove a style

3. Switch the style

TaggleClass () // you can switch the class styles of different elements.

Iii. Class capacity operations

1.html code operations

Html ([content]) // (optional) specifies the new category of the alternative element. This parameter can contain HTML tags. If no parameter exists, it indicates the Text Category of the selected element.

2. Label operations

Text ([content]) // optional, specifying the new text class of the selected element. annotation. special characters are encoded. If no parameter is specified, it indicates obtaining the selected class capacity of the element.

3. Attribute Value operation

Val ([value])

Iv. node attribute operations

1. Search for nodes

$ ("Xxx ")

2. Create a node

$ (Selector) // selector

$ (Element) // Dom element

$ (Html) // html code

3. Insert a node

Internal insertion: append (content) appendTo (content) prepend (content) prependTo (content)

External insertion: after (content) insertAfter (content) before (content) insertBefore (content)

4. delete a node

$ (Selector). remove ([expr])

5. Replace nodes

$ ("Ul li: eq (1)"). replaceWith ($ xxx)

6. Copy a node

$ (Selector). clone ([includeEvents])

 

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.