On 12/14/06, Dave Methvin <[EMAIL PROTECTED]> wrote:

*SNIP*
It would be nice if there was a $().grep() to filter the elements:

$("[EMAIL PROTECTED]:not(.thickbox)").grep(function(){
    for ( var i=0; i < notthese.length; i++ )
        if ( this.href == notthese[i] ) return false;
    return true;
  }).bind("click", function(){ return !window.open(this.href); });

But that doesn't exist. There's a jQuery.grep but it can't be used in a
chain.


I looked at 1.0.3 source and filter() accepts a function and it appears that
if that function returns true the element is included otherwise it returns
false. The function you define takes two args: element, and i with i being
the position in the current list or stack.

(Untested)
$("[EMAIL PROTECTED]:not(.thickbox)").filter(function(el){
   for ( var i=0; i < notthese.length; i++ )
   if (el.href == notthese[i] ) return false;
       return true;
   }).bind("click", function(){ return !window.open(this.href); });

Cheers,
-js
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to