4

Hi there are something wrong with this selector

document.querySelectorAll('img:not(img[src^="data"])');

I need to get all images which does not having a data url,

my developer console saying that

VM701:1 Uncaught DOMException: Failed to execute 'querySelectorAll' on 'Document': 'img:not(img[src^="data"])' is not a valid selector.
Sajan
  • 813
  • 9
  • 14
  • No way this is not a duplicate for https://stackoverflow.com/questions/10711730/why-is-my-jquery-not-selector-not-working-in-css. First of all, that one is jQuery, this one vanilla JS. Second and more important, that one is about differences with jQuery/JS and CSS implementation of the selector. That one may have the solution for this in somewhere, it may serve as additional reading; but what's only needed here, is Sandeep simple explanation of *misuse* of the selector. – Andre Figueiredo Dec 14 '18 at 04:32

1 Answers1

4

It should just be ...img:not([src^="data"])...

document.querySelectorAll('img:not([src^="data"])');

Read more about attribute selector here

Sandeep Nayak
  • 4,649
  • 1
  • 22
  • 33