What is the opposite of Jquery .not - OR - How to I target href links that contain the following....

Posted by stolkramaker on Stack Overflow See other posts from Stack Overflow or by stolkramaker
Published on 2010-04-22T14:36:57Z Indexed on 2010/04/22 14:43 UTC
Read the original article Hit count: 195

Filed under:

Right. So here we go.

I am currently using the following code to target all links and apply an iframe toolbar

$("a[href^='http:']").not("[href*='www.domiain.com']").not("[href*='www.twitter.com']").each(function(){ 
 var tempurl = 'http://www.domain.com/shiftbar/shiftbar.html?iframe=';
 var $this = $(this);
 var currenturl = this.getAttribute("href");
    var href = tempurl + currenturl;
 $this.attr('href', href ); 
});

I need to do the same, but now for links that ONLY contain twitter

$("a[href^='http:']").contains("[href*='www.twitter.com']").each(function(){ 
 $this.attr("target", "_blank");
});

it doesn't work. I've tried

.has
.contains

But I suppose I am not familiar with jquery enough at this point.

© Stack Overflow or respective owner

Related posts about jQuery