> I was just looking at this again, and wondered how I could
> make it work with a string of links to not be external.  For
> example using a for loop to go through var intLink = link1,
> link2, link3, etc. 
>
>  $("[EMAIL PROTECTED]:not([EMAIL PROTECTED]'"+intLink+"']):not(.thickbox)")
>    .bind("click", function(){ return !window.open(this.href); });

You could do it by creating a custom selector that joined a bunch of :not()
clauses:

 var notthese = ["http://test.com";, "http://toast.com";];
 var sel = "[EMAIL PROTECTED]:not(.thickbox)";
 for ( var i=0; i < notthese.length; i++ )
     sel += ":not(@href*="+notthese[i]+")";
 $(sel).bind("click", function(){ return !window.open(this.href); });

Or you could filter them manually:

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

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.


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to