8

这是原始代码的链接: http: //css-tricks.com/snippets/jquery/make-jquery-contains-case-insensitive/#comment-518214

http://css-tricks.com/snippets/jquery/make-jquery-contains-case-insensitive/#comment-518214

1) 在上面的代码中,什么是 $.expr[:]?2) 什么是 $.expr.createPseudo?

我找不到任何关于它的文件!!!为什么他们提供这个没有文件?非常沮丧!!!!!!!!!!!!

4

2 回答 2

7

1) in th above code, what is $.expr[:]? 2) what is $.expr.createPseudo?

It's how you extend Sizzle selectors. See the docs.

Sizzle is the DOM query engine used by jQuery.

于 2013-08-18T02:28:54.850 回答
2

$.expr包含一个对象,该对象持有对嘶嘶声伪选择器的引用。 $.expr.createPseudo是一种为扩展$.expr对象而设计的方法,因此您可以实现新的伪选择器。

例如,

$.expr[':'].wide = $.expr.createPseudo(function () {
    return function (elem) {
        return $(elem).width() > $(elem).height();
    }
}); 

这是一个 jsFiddle

这是 sizzle 文档的 github

于 2013-08-18T02:41:06.193 回答