UNPKG

apex4x

Version:

The Comprehensive ARIA Development Suite

37 lines 2.71 kB
�� Function: lastChild(domElementOrStringMarkupOrCSSSelector, functionConfirm(domElement)) Shorthand: last(domElementOrStringMarkupOrCSSSelector, functionConfirm(domElement)) Description: Returns the last child element. Returns: domElement, or $A object if chained. Note: When the second parameter is undefined, lastChild() returns the last child DOM element. When the second parameter is set to a function however, it must return true in order for the current node to be returned. This exists for cases when specific criteria are needed, such as a matching tag name or element type. Example: // Return the last child DOM element. var myElement = $A.lastChild(domElement); // Return the last child DOM element, but only when specific criteria is confirmed. var myElement = $A.lastChild(domElement, function(node) { if (node.nodeName.toLowerCase() === "h2") return true; }); // Or the same using chaining // Return the last child DOM element. var myChain = $A(domElement).lastChild(); // Return the last child DOM element, but only when specific criteria is confirmed. var myChain = $A(domElement).lastChild(function(node) { if (node.nodeName.toLowerCase() === "h2") return true; }); // To return the modified element within a chain, use the "return()" method. var myElement = myChain.return();