最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

what is $.expr[":"] in javascript or jQuery? - Stack Overflow

programmeradmin3浏览0评论

here is the link to original code:

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

I can't find any document about it!!! Why they provide this without document? very frustrated!!!!!!!!!!!

here is the link to original code: http://css-tricks./snippets/jquery/make-jquery-contains-case-insensitive/#ment-518214

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

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

I can't find any document about it!!! Why they provide this without document? very frustrated!!!!!!!!!!!

Share Improve this question asked Aug 18, 2013 at 2:23 Nicolas S.XuNicolas S.Xu 14.6k34 gold badges88 silver badges138 bronze badges 1
  • it is an internal function o jquery used to create jQuery expressions – Arun P Johny Commented Aug 18, 2013 at 2:26
Add a ment  | 

2 Answers 2

Reset to default 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.

$.expr contains an object that holds reference to the sizzle pseudo selectors. $.expr.createPseudo is a method designed for extending the $.expr object so you can implement new pseudo selectors.

For example,

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

Here's a jsFiddle

Here's the github for sizzle docs

发布评论

评论列表(0)

  1. 暂无评论