Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does jQuery.expr[':'] work and where is it documented for jQuery1.8.x and later?

Tags:

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.

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.

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

I've looked at jQuery.filter but can't figure out an alternative to Lupton's technique in his ajaxify script.

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.

like image 778
DavidHyogo Avatar asked Feb 10 '13 12:02

DavidHyogo


1 Answers

It's part of Sizzle which is the selector engine that jQuery uses.

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

like image 139
bob_cobb Avatar answered Sep 27 '22 20:09

bob_cobb