Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Can the index in each jquery be customized?
Can the index in each jquery be customized?
For the jQuery object, we simply delegate the each method: pass the jQuery object as the first parameter to the each method of jQuery. In other words, the each method provided by jQuery calls all the child elements of the object provided by the parameter 1 one by one.

Each (callback)

Executes a function in the context of each matched element.

This means that every time an incoming function is executed, the this keyword in the function points to a different DOM element (a different matching element every time). Moreover, every time a function is executed, a numerical value representing the position of an element as an execution environment in the matching element set is passed to the function as a parameter (zero-based shaping). Returning "false" will stop the loop (just like using "break" in a normal loop). Return "True" to jump to the next loop (just like using "Continue" in a normal loop).

Callback is a callback function, which indicates the operation that should be given when traversing the element. Let's look at the following simple example:

Iterate over two images and set their src properties. Note: This refers to the DOM object, not the jQuery object.