Native js implements the next method of jQuery?

ask for advice, thank you

Jun.03,2021

JQuery itself is the encapsulation of JS, and you can get the answer by looking up the source code of JQuery. If you want to write your own traversal JS, you can first refer to the source code of JQuery and the traversal code of other languages, which should be helpful to encapsulate the native JS.

for more information on the source code, please refer to the following blog content written by nuysoft:
http://www.cnblogs.com/nuysof.

. The next () of

JQuery is mainly implemented through two basic attributes of HTML DOM, nodetype and nextsibling. Some of these functions also involve attributes such as parentNode,children.
some common native JS is also written around these basic HTML properties and JS syntax.

The

HTML DOM nodetype attribute
nodeType property returns the node type of the specified node as a numeric value.
if the node is an element node, the nodeType attribute returns 1.
.
if the node is document, the nodeType property returns 9.

HTML DOM nextSibling attribute
nextSibling attribute: this attribute represents the next node of the current node; if there is no node of the same level thereafter, it returns null;

JQuery traversal iterates through three core functions
jQuery.dir (elem, dir, until), starting from one element, iteratively retrieves all elements in a certain direction and records until the element jQuery.nth (cur, result, dir, elem) that matches the document object or until starts from one element, iteratively retrieves all subsequent sibling elements of the nth element jQuery.sibling (n, elem) element n in a certain direction, including n, excluding elem

.
Menu