Log in Sign up
3 Matching Annotations
  1. Mar 2021
  2. stackoverflow.com stackoverflow.com
    Native javascript equivalent of jQuery :contains() selector
    2
    1. TylerRick 10 Mar 2021
      in Public
      [...document.querySelectorAll("*")].filter(e => e.childNodes && [...e.childNodes].find(n => n.nodeValue?.match("❤")))
      DOM: search for elements containing text targeting modern version of JavaScript concise
    2. TylerRick 10 Mar 2021
      in Public
      function contains(selector, text) { var elements = document.querySelectorAll(selector); return [].filter.call(elements, function(element){ return RegExp(text).test(element.textContent); }); }
      DOM: search for elements containing text
    Visit annotations in context

    Tags

    • concise
    • targeting modern version of JavaScript
    • DOM: search for elements containing text

    Annotators

    • TylerRick

    URL

    stackoverflow.com/questions/17799236/native-javascript-equivalent-of-jquery-contains-selector
  3. stackoverflow.com stackoverflow.com
    Javascript .querySelector find <div> by innerTEXT
    1
    1. TylerRick 10 Mar 2021
      in Public
      Array.from(document.querySelectorAll('div')) .find(el => el.textContent === 'SomeText, text continues.');
      DOM: search for elements containing text
    Visit annotations in context

    Tags

    • DOM: search for elements containing text

    Annotators

    • TylerRick

    URL

    stackoverflow.com/questions/37098405/javascript-queryselector-find-div-by-innertext
Share:
Group. Only group members will be able to view this annotation.
Only me. No one else will be able to view this annotation.
Hypothes.is
  • About
  • Blog
  • Bioscience
  • Education
  • Jobs
  • Help
  • Contact
  • Terms of Service
  • Privacy Policy