Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Get the deepest children of each element in the set of matched elements, optionally filtered by a selector.

License

Notifications You must be signed in to change notification settings

martinille/jquery.deepest.js

Open more actions menu

Repository files navigation

jquery.deepest.js

A plugin that allows developers to access the deepest children of a DOM element, and is less than 1kb in size.

Retrieve the children at the deepest level of the DOM tree for each element in the set of matched elements, with the option to filter these children using a selector.


Install with npm

npm i jquery.deepest.js

Usage

HTML content:

<div id="test1">
    <div class="level1">
        <div class="level2">
            <div class="level3"></div>
        </div>
    </div>
</div>

<div id="test2">
    <ul>
        <li><a href="#">link1</a></li>
        <li><a href="#">link2<span></span></a></li>
        <li><a href="#">link3</a></li>
    </ul>
</div>

JavaScript:

let $deepest1 = $("#test1").deepest();
console.log($deepest1); // returns JQuery element '<div class="level3"></div>'

let $deepest2 = $("#test2").deepest('span');
console.log($deepest2); // returns JQuery element '<span></span>'

About

Get the deepest children of each element in the set of matched elements, optionally filtered by a selector.

Topics

Resources

License

Stars

Watchers

Forks

Morty Proxy This is a proxified and sanitized view of the page, visit original site.