Home > Article > Web Front-end > jQuery traversal next(), nextAll() method usage examples_jquery
jquery traversal: next() and nextAll() methods. Examples are as follows:
I am p tag
I am also a p tag
Description:
(1) next() method: refers to obtaining the adjacent sibling elements of the matching element (i.e. the next sibling element). Note that the sibling elements are not elements with the same label, but refer to the closed next sibling element of the element. An element, such as "
.
(2) If next() adds a parameter, that is, next("div"), if the next adjacent element is not a div, it will be empty, that is, it must be adjacent.
(3) nextAll() method: refers to obtaining all sibling elements after the matching element. It can also add parameters, nextAll("p") or nextAll("div"), etc.
(4) Something strange is that if it is this code:
It does not get all the html content, but only the html content of the next sibling element. ? ? ? Doubt