Posted By

1man on 01/11/10


Tagged

jquery expand selector custom expr


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

nerdfiles
cro1979
rygiel


Custom jQuery selector


 / Published in: jQuery
 

Example given in the book jQuery Enlightenment.

Create your own custom selectors in jQuery and manipulate as usual.

  1. $.expr[":"].positionAbsolute = function(el){
  2. return $(el).css("position") === "absolute";
  3. };
  4.  
  5. //Usage
  6. alert($(":positionAbsolute").length); //alerts number elements positioned absolutley
  7.  
  8. //Or use a filter
  9. $("div").filter(function(){return $(this).css('position') === 'absolute';});

Report this snippet  

You need to login to post a comment.