0

I'm getting an error that I haven't seen before and not sure as to why

I'm looking for a specific element on a page using jQuery

$(".bmr-dropdown-menu-item__text") works as expected. However when I try to search the innerHTML of all of the results using :contains() I get an error.

What am I doing wrong?

$(".bmr-dropdown-menu-item__text")
<span class="bmr-dropdown-menu-item__text ng-binding">Cold Prospect</span>
$(".bmr-dropdown-menu-item__text:contains('Cold')")
VM4277:1 Uncaught DOMException: Failed to execute '$$' on 'CommandLineAPI': '.bmr-dropdown-menu-item__text:contains('Cold')' is not a valid selector.
    at <anonymous>:1:1
Morgan Allen
  • 3,291
  • 8
  • 62
  • 86
  • Can you post the source and any errors as text? That screenshot is too tiny to read, it's just smudges. – tadman Dec 10 '18 at 15:57
  • if you click on it, it should make it bigger in imgur. I'm injecting some code into a web page to find a button on a page to click. – Morgan Allen Dec 10 '18 at 15:58
  • That's not a solution. Just copy-paste the error as text and it'll be instantly readable for everyone, not just people who mess around and view it on Imgur. – tadman Dec 10 '18 at 15:59
  • 1
    ok,doing that now! thanks – Morgan Allen Dec 10 '18 at 15:59
  • Are you sure this is just jQuery? `$` is the jQuery selector. `$$` is some extension to it. – tadman Dec 10 '18 at 16:03
  • `$` is `querySelector` and `$$` is `querySelectorAll`. It seems that `$` will only select the first element of the results, vs `$$` will return the entire list. – Morgan Allen Dec 10 '18 at 16:05
  • oooh I see. I understand now. just using `$` with `:contains()` worked – Morgan Allen Dec 10 '18 at 16:05
  • Might be a duplicate of [this question](https://stackoverflow.com/questions/13933157/what-is-the-difference-between-and). – tadman Dec 10 '18 at 16:06
  • nevermind, still getting the same error `$(".bmr-dropdown-menu-item__text:contains('Warm')") VM4379:1 Uncaught DOMException: Failed to execute '$' on 'CommandLineAPI': '.bmr-dropdown-menu-item__text:contains('Warm')' is not a valid selector. at :1:1` – Morgan Allen Dec 10 '18 at 16:08

0 Answers0