javascript - 用 jQuery 方法替换 not had css 查询选择器

标签 javascript jquery jquery-selectors

是否可以将 $('div:not(:has(video))') 替换为 .not.has

最佳答案

如果您阅读文档,您将找到问题的答案:

queries using :has() cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method. For better performance in modern browsers, use $( "your-pure-css-selector" ).has( selector/DOMElement ) instead.

https://api.jquery.com/has-selector/

The .not() method will end up providing you with more readable selections than pushing complex selectors or variables into a :not() selector filter. In most cases, it is a better choice.

https://api.jquery.com/not-selector/

关于javascript - 用 jQuery 方法替换 not had css 查询选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34403958/

相关文章:

PHP 相当于这个 Javascript

javascript - 防止子元素触发 jQuery 事件

jquery - jqGrid 自定义 onCellSelect 在SaveCell 之前不触发

javascript - 使用 z-index 那么为什么在 html 中显示背景对象

php - Javascript:如何使用服务器上的html文件而不是URL来window.open?

在 WordPress index.html 中处理 PHP 的 JavaScript 导致加载问题,不匹配 fiddle 代码

jquery - 编写 jQuery 选择器不区分大小写的版本

javascript - jQuery 获取搜索选择器,如果元素不存在

javascript - Jquery:获取每个图像src

javascript - 如何扩展一个javascript对象?