Skip to content

Instantly share code, notes, and snippets.

@bitsprint
Created June 11, 2019 09:06
Show Gist options
  • Select an option

  • Save bitsprint/16f50ef435bb843f28c502687379a51f to your computer and use it in GitHub Desktop.

Select an option

Save bitsprint/16f50ef435bb843f28c502687379a51f to your computer and use it in GitHub Desktop.

Revisions

  1. bitsprint revised this gist Jun 11, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion climb-the-dom.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@

    var el = $('#some-element');
    var selector = '#some-elements-parent-further-up-the-dom');
    var selector = '#some-elements-parent-further-up-the-dom';

    for ( ; el && el !== document; el = el.parentNode ) {
    if ( el.matches( selector ) ) return el;
  2. bitsprint created this gist Jun 11, 2019.
    7 changes: 7 additions & 0 deletions climb-the-dom.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@

    var el = $('#some-element');
    var selector = '#some-elements-parent-further-up-the-dom');

    for ( ; el && el !== document; el = el.parentNode ) {
    if ( el.matches( selector ) ) return el;
    }