parentNode is native JS, where parent () is not.
What you do in your code is to wrap the DOM elements in a jQuery object so that you can call jQuery-specific methods for it. Thus, you cannot call index () only for this.parentNode, but you can call it for $ (this.parentNode) .index () since it became a jQuery object.
Your first example wraps the current DOM element as a jQuery object, and then uses the jQuery parent () method to get its parent, and then the index of that parent. Your second example directly wraps the parent node.
Bas slagter
source share