Using weenstmcri One of the most powerful aspects of jQuery is its ability to make selecting elements in the DOM easy. the Document Object Model serves as the interface between JavaScript and a web page; it provides a representation of the source HTML as a network of objects ra One of the most powerful capabilities of ther than as plain text. jquery is its ability to easily change elements in the DOM structure. The Document Object Model is used as the js and webpage interfaces. It provides basic html as the object network rather than simple text. This network takes the form of a "family tree" of elements on the page. when we refer to the relationships that elements have with one another, we use the same terminology that we use when referring to family relationships: parents, children, and so on. A simple example can help us understand how the family tree metaphor applies to a document, as follows: The title
This is a paragraph.
This is another paragraph.
This is yet another paragraph.
The mesh structure is shown as a home map on the webpage. When we talk about the relationship between an element and other elements, we use the actual term "family relationship": "parent", "child", and so on. A simple example can help us understand how the home map is mapped to the document, as shown below: The title
This is a paragraph.
This is another paragraph.
This is yet another paragraph.
Here,Is the ancestorof all the other elements; in other words, all the other elements are descendantsof.AndElements are not only descendants, but childrenof, As well. Likewise, in addition to being the ancestorAnd,Is also their parent.
Elements are children (and descendants) of, descendantsAnd, And siblingsof each other, as shown in the following disince: Here,Is the ancestor of all other elements. In other words, all other elements are.AndThe element is not only a descendant element, but alsoChild element. Similarly,Not only are their ancestor elements, but also their parent generation.
Element is a child element, which is also a child element.AndThe descendant element of is also another
Brother element. As shown in the following chart. To help visualize the family tree structure of the DOM, you can use a number of software tools, such as the Firebug plugin for Firefox, or the Web Inspector in Safari or Chrome. to help make the family book structure of the DOM structure more vivid, you can use some software tools, such as firebug plug-ins on firefox, or web probes on Safari or Chrome. With this tree of elements at our disposal, we'll be able to use jQuery to efficiently locate any set of elements on the page. our tools to achieve this are jQuery selectors and traversal methods. through the element tree we use, we can use jquery to effectively locate any element on the web page. The tool we use to achieve this is the jquery selector and Traversal method. An important point to note, before we begin, is that the resulting set of elements from selectors and methods is always wrapped in a jQuery object. these jQuery objects are very easy to work with when we want to actually do something with the things that we find on a page. we can easily bind eventsto these objects and add slick into tsto them, as well as chainmultiple modifications or effects toget Her. nevertheless, jQuery objects are different from regular DOM elements or node lists, and as such do not necessarily provide the same methods and properties for some tasks. in the final part of this chapter, therefore, we will look at ways to directly access the DOM elements that are wrapped in a jQuery object. before we start, it is important to note that the result of the selector and method is surrounded by the stone jquery object. When we want to actually do something on the elements we find on the web page, it is easy to use these jquery objects. We can easily bind events to these objects, add smooth effects to them, and chain modifications affect them. Jquery objects are different from conventional DOM objects or node lists, and it is not necessary to add the same methods and attributes for some tasks. Therefore, in the last part of this chapter, we will take a look at directly accessing the DOM objects surrounded by jquery objects.