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.
1
  • No way this is not a duplicate for stackoverflow.com/questions/10711730/…. 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. Commented Dec 14, 2018 at 4:32

1 Answer 1

4

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

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

Read more about attribute selector here

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.