Access the DOM in jQuery
jQuery is a very powerful tool. It provides various DOM access methods (DOM Traversal Method), which helps us to select elements in a document randomly or in a continuous manner.
jQuery is a very powerful tool. It provides various DOM access methods (DOM Traversal Method), which helps us to select elements in a document randomly or in a continuous manner.
Most DOM Traversal Method does not modify jQuery objects and they are used to filter their elements from a document based on the given conditions.
Search for elements by index in jQuery
Consider the following example of a simple document with the following HTML content:
The JQuery Example
list item 1 list item 2 list item 3 list item 4 list item 5 list item 6
It will produce the following result:
- list item 1
- list item 2
- list item 3
- list item 4
- list item 5
- list item 6
Above, each list has its own index, and can be located using the eq (index) method as in the example below.
Each child element starts its index from 0, so list item 2 will be accessed using $ ("li"). Eq (1) and so on.
For example
Simple example after adding color to the third item list .
The JQuery Example