javascript jQuery.expr[':'] 是如何工作的,它在 jQuery1.8.x 和更高版本中的文档在哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14797569/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How does jQuery.expr[':'] work and where is it documented for jQuery1.8.x and later?
提问by DavidHyogo
I've looked all over for some clear documentation on this syntax. It is used to create custom filters to select very specific elements in the DOM. There is a good example by Benjamin Arthur Lupton in the ajaxify-html5.js gist example (see line 45 where the function is defined and line 78 where it is used), which he provides to show how to ajaxify a web site using his history plug-in.
我已经四处寻找有关此语法的清晰文档。它用于创建自定义过滤器以选择 DOM 中非常特定的元素。Benjamin Arthur Lupton 在ajaxify-html5.jsgist 示例中有一个很好的示例(参见定义函数的第 45 行和使用函数的第 78 行),他提供的示例展示了如何使用他的历史记录对网站进行 ajaxify插件。
There is also a fairly extensive blog by Shane Riley called Adding Filter Expressions, but I've scoured through the jQuery documentation and I can't find any documentation.
Shane Riley 还有一个相当广泛的博客,名为“添加过滤器表达式”,但我已经浏览了 jQuery 文档,但找不到任何文档。
I would be grateful if you could either
如果你能,我将不胜感激
- point me to the official documentation for the
expr
function - show me where to find it in the source files (I've looked - can't find it)
- or suggest alternative syntax based on a technique that is properly documented
- 将我指向该
expr
函数的官方文档 - 告诉我在源文件中的哪里可以找到它(我已经看过了 - 找不到)
- 或根据正确记录的技术建议替代语法
I've looked at jQuery.filter
but can't figure out an alternative to Lupton's technique in his ajaxify script.
我已经看过jQuery.filter
但无法在他的 ajaxify 脚本中找到 Lupton 技术的替代方案。
I'm keen to work with a recent jQuery. I'm working with v 1.8.2 and will be aiming to upgrade to 1.9.x soon.
我很想使用最近的 jQuery。我正在使用 v 1.8.2,并将尽快升级到 1.9.x。
采纳答案by bob_cobb
It's part of Sizzlewhich is the selector engine that jQuery uses.
它是Sizzle的一部分,它是 jQuery 使用的选择器引擎。
They now have documentation explaining its usage with examples for pre and post 1.8.x: https://github.com/jquery/sizzle/wiki/Sizzle-Documentation#-pseudo-selectors
他们现在有解释其用法的文档,包括 1.8.x 之前和之后的示例:https: //github.com/jquery/sizzle/wiki/Sizzle-Documentation#-pseudo-selectors