2017-01-10 34 views
3

你好有什么不对的选择的JavaScript querySelector不与工作“:不是()”选项

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

我需要得到它不具有数据网址的所有图像,

我开发者控制台说

VM701:1 Uncaught DOMException: Failed to execute 'querySelectorAll' on 'Document': 'img:not(img[src^="data"])' is not a valid selector. 

回答

4

这应该只是...img:not([src^="data"])...

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

了解更多关于attribute选择here