The jQuery operation gets the DOM element, and jQuery operates the DOM element.
JQuery provides some functions and usage methods for DOM operations. Here, we will briefly describe how to use DOM elements and flexibly use other methods. The following
Every selector expression and most jQuery methods return a jQuery object. This is almost always what we want, because of the implicit iteration and chaining capabilities that it affords.
Still, there may be points in our code when we need to access
Attribute and property all have attribute meanings, but it is not difficult to distinguish between attribute and properties. From an object, attribute is a label attribute on an HTML document,The property is the self-attribute of the corresponding
DOM element Basic Operation Method API, first record, easy to use later.
The consortium DOM and JavaScript are easily confusing. The DOM is an API for HTML and XML documents that provides a structured representation of the document and defines how
Problem Introduction:
A DOM element binds two events, one bubbling, one capture, how many times the event executes, and the order of execution.
This time do not sell thinking, directly give you an answer. If you don't understand it, keep looking
This example describes the jquery traversal DOM element and node method. Share to everyone for your reference, specific as follows:
One, up traversal--ancestor element
①$ (selector). parent ([filter]): Returns the direct parent element of a
You can use the get method to obtain DOM elements after jQuery $ is called, as shown below:
Copy codeThe Code is as follows: // method 1
$ ('Div '). get (1); // obtain the second div on the page
Of course, you can also use the array index method to
JavaScript gets DOM element position and sizeIn some complex pages, we often use JavaScript to deal with some of the dynamic effects of DOM elements, which is often used to calculate the location and size of some elements, the browser compatibility
Before the jQuery1.8.0 version, we wanted to get an event handler for a DOM binding to do this: $.data (domobj, ' events '); // or $ (' selector '). Data (' Events ')jquery1.8. Beginning with version 0, jquery suddenly does not support this use,
1. Add DOM element append prepend before afterAppend add a previous instance of the sibling element: add node after sibling element var pageup = ' append after the sibling element ';$ ('. Header '). On (' click ', function () {$ (this). Append
DOM elements have some standard events. Generally, you only need to use the onclickfunction method. However, when you need to add multiple events to the DOM element, delete the event, or when Javascript is used to encapsulate controls, DOM elements
Get one of the matching elements: index means to get the first few matching elements, which allows you to select an actual DOM element and manipulate it directly, rather than through the JQuery function. $ (this). Get (0) is equivalent to $ (this) [0
1. DOM element properties for working with XML documentsProperty name DescriptionChildNodes returns an array of all child elements of the current elementFirstChild returns the first subordinate child element of the current elementLastChild returns
Events that are bound to clicked elements occur in code order, and other elements are bubbling or capturing "perceived" events, which, according to the criteria of the standard, capture the event, and then a bubbling event occurs. The order of all
HiKeep Learning quantity and quality1. jquery Operation DOM Element----Control the attributes of an element using the attr () methodattr()The function of a method is to set or return the attributes of an element, where the attr(属性名) format is the
JQuery displays the list of events bound to the dom element, jquerydom
As a technical enthusiast, you can't help but wonder how a technical product is implemented. For example, I can't help opening the browser console every time I see a dazzling
The index of the element, relative to the selectorGets the index position of the element relative to the selector.The element can be specified by a DOM element or JQuery selector.Grammar$ (selector). Index (element)$ (". Hot"). Index ($ ("#favorite")
Used to process DOM element attributes of XML documents
Attribute Name Description
ChildNodes returns an array of all child elements of the current element.
FirstChild returns the first sub-element of the current element.
LastChild returns the last
This article mainly introduces the second parameter of the jQuery function to obtain the DOM element in the specified context. If you need it, you can refer to the second parameter of the jQuery function to specify the search range of the DOM
InitiateMany front-end class libraries, such as Dojo and jquery, will see two modules when it comes to DOM operations: attr, Prop. One day when the code review, see a section of the code to set the text for a node:attr. Set ' InnerText ' ' Hello
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.