javascript querySelector 不适用于 ':not()' 选项

标签 javascript css css-selectors jquery-selectors

<分区>

你好,这个选择器有问题

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

我需要获取所有没有数据 url 的图像,

我的开发者控制台是这样说的

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

最佳答案

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

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

阅读更多关于 attribute 选择器的信息 here

关于javascript querySelector 不适用于 ':not()' 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41561468/

相关文章:

css - 我可以定位 :before or :after pseudo-element with a sibling combinator?

CSS语法,如何使用li.class :hover?

javascript - Cypress 在自定义命令中加载环境变量

javascript - jQuery:仅当页面上当前没有运行 AJAX 时才提交表单

javascript - 处理西里尔编码的 Node js有什么问题

html - Chrome 工作区的局限性

html - 适合对象 : cover - is not working with video tags without border-radius

javascript - 如何获取两个输入事件内两个不同函数内且都在本地范围内的两个变量的总和?

html - 用 CSS 重构 HTML

python - 在 Scrapy 中使用第 nth-child