jquery Experience 3--jquery Introductory knowledge Management 2

Source: Internet
Author: User

A blog post jquery management 1

1. Form Object Properties Filter Selector

This selector mainly filters the selected form elements

2. Form Selector

3. DOM operations in JQuery

DOM (Document Object model-model): A browser-and-platform, language-independent interface that makes it easy to access all the standard components in a page

Classification of DOM operations:

Dom Core:dom Core is not specifically JavaScript, and can be used by any programming language that supports DOM. Its use is not limited to processing Web pages, but can also be used to handle any kind of document written in markup language, for example: XML

HTML DOM: when scripting HTML files with JavaScript and Dom, there are many attributes that are html-dom-specific

css-dom: For CSS operations, in JavaScript, Css-dom is primarily used to get and set various properties of a style object

4. The specific function realizes

Lookup node:

Find element node: done through the jQuery selector.

Lookup attribute node: After you find the element you want, you can call the attr () method of the JQuery object to get its various property values

To Create a node:

Use JQuery's Factory function $ (): $ (HTML); Creates a DOM object based on the passed-in HTML tag string and wraps the DOM object back into a JQuery object.

Note:

Dynamically created new element nodes are not automatically added to the document, but need to be inserted into the document using other methods;

When creating a single element, be aware of closing the label and using the standard XHTML format. For example, to create a <p> element, you can use $ ("<p/>") or $ ("<p></p>"), but you cannot use $ ("<p>") or $ ("<P>")

Creating a text node is simply writing the text content when you create the element node. Creating an attribute node is also created together when the element node is created

Insert Node

Creating HTML elements dynamically is not practical, and you need to insert a newly created node into a document that becomes a child of a node in a document

The above method not only inserts the newly created DOM elements into the document, but also moves the existing DOM elements.

Delete a node

Remove (): Deletes all matching elements from the DOM, and the incoming arguments are used to filter the elements based on the jQuery expression. When a node is deleted with the Remove () method, all descendant nodes that the node contains are deleted at the same time. The return value of this method is a reference to a node that has been deleted.

Empty (): Clears the node-clears all descendant nodes in the element (not including the attribute node).

Replication Node

Clone (): Clones a matching DOM element and returns a cloned copy of the value. However, the new node being replicated does not have any behavior at this time.

Clone (True): Copies an element and also copies the events in the element

replacing Nodes

ReplaceWith (): Replaces all matching elements with the specified HTML or DOM element; ReplaceAll (): The Reversed ReplaceWith () method.

Note: If an event has been bound on the element before replacing it, the event that the original binding will disappear with the original element

Parcel Node

Wrap (): Specifies that nodes are wrapped with other tags. This method is useful for inserting additional structured markup in a document, and does not break the semantics of the original document.

Wrapall (): Wraps all matching elements in one element. The Wrap () method is to wrap all the elements separately.

Wrapinner (): Wraps the child contents of each matched element (including text nodes) with other structured tags.

Using the Wrapall () method requires attention to whether the node being wrapped belongs to a "set of nodes," and if it is not a group, the side effect of the "Move Node" occurs

5. Property action

L attr (): Getting Properties and setting properties

When a parameter is passed for the method, the property is specified for the acquisition of an element

When two arguments are passed for this method, the value of the specified property is set for an element

Many of the methods in JQuery are a function implementation gets and sets. such as: attr (), HTML (), text (), Val (), Height (), Width (), CSS (), etc.

L removeattr (): Deletes the specified attribute of the specified element

L reads and sets the HTML content in an element : html () . This method can be used for XHTML, but not for XML documents

L reads and sets the text content in an element: Text (). This method can be used both for XHTML and for XML documents.

L reads and sets the value in an element: Val () ---The method is similar to the Value property in JavaScript. For text boxes, Drop-down list boxes, radio boxes This method returns the value of the element (the multiple-selection box can only return the first value ). If you are a multiple-selection drop-down list box, returns an array that contains all of the selected values

6. The commonly used traversal node method

L Gets a set of all the child elements of the matching element: children (). This method takes only child elements into account, regardless of any descendant elements.

L GETS the collection of sibling elements immediately following the matching element (but only one element in the collection ): Next ()

L GETS the collection of sibling elements immediately preceding the matching element (but only one element in the collection ): prev ()

L get all sibling elements before and after matching elements: siblings ()

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.