« Return to Thread: Change href of external links

Re: Change href of external links

by dave.methvin :: Rate this Message:

Reply to Author | View in Thread

> One question: is it not possible to combine .not arguments?
> Tried playing with the quotes, but it only seems to work if
> they are separated.
>
> .not("[@href*='internal.com/']")
> .not("[@class*='thickbox']")

Even better, you could use the :not() selector to do the job all at once, I
forgot about it.

  $("a[@href=^http]:not([@href*='internal.com/']):not(.thickbox)")
     .bind("click", function(){ return !window.open(this.href); });

This is the way jQuery optimization usually goes. You start with 10 lines of
jQuery that would have been 20 lines of tedious DOM Javascript. By the time
you are done it's down to two or three lines and it couldn't get any shorter
unless it read your mind. :-)



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

 « Return to Thread: Change href of external links