Skip to content

Instantly share code, notes, and snippets.

@victoralvesf
Created August 6, 2020 14:16
Show Gist options
  • Select an option

  • Save victoralvesf/7973133d47300dfa1cd02b70935f9c85 to your computer and use it in GitHub Desktop.

Select an option

Save victoralvesf/7973133d47300dfa1cd02b70935f9c85 to your computer and use it in GitHub Desktop.

Find elements using css selector with expressions:

Example: <input type="text" placeholder="Search..." class="form-control">

How to find this element:

  • By the start string of placeholder

    $('input[placeholder^=Search]') // returns true

    $('input[placeholder^=earch]') // returns false

  • By the end of string

    $('input[placeholder$="..."]') // returns true

    $('input[placeholder$=Search]') // returns false

  • By a part of string

    $('input[placeholder*=Search]') // returns true

    $('input[placeholder*=Sear]') // returns true

    $('input[placeholder*="S..."]') // returns false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment