JQuery replacement of closing hyperlink tag if http is in the href tag #2

Hi,

In a previous post, an Expert provided a solution that places and image with alternate text next to the links that are to external sites (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_27974488.html).  I need a to revise their solution so that if I add a class="internal" to the link the Jquery will not add the image to the right of the link.
atljarmanAsked:
Who is Participating?
 
soupBoyConnect With a Mentor Commented:
Yeah, jsFiddle really only works well on modern browsers...

Here is the modified jsFiddle: Using .not() with .filter()

It does in fact work.

- Chris
0
 
soupBoyCommented:
Odds are there is a better way to do this, possibly within the .filter() method...but I haven't used filter before...

$("a").filter(function() { return $(this).attr("href").indexOf("http")==0; }).not('.internal').after('<span class="dropt" title="Redirect Disclaimer"><img src='images/redirect.png' title='Redirect Disclaimer'/><span style="width:350px;">Text of the Disclaimer Here </span></span>');

Open in new window


I added the .not('.internal') just after .filter()
0
 
atljarmanAuthor Commented:
Can you modify the jsfiddle?  Unfortunately, jsfiddle isn't allowing the editing of the jquery syntax, at least not from IE8.

What you are saying is this is how it woudl look in the body of the page:

<script>
$("a").filter(function() { return $(this).attr("href").indexOf("http")==0; }).not('.internal').after('<span class="dropt" title="Redirect Disclaimer"><img src='images/redirect.png' title='Redirect Disclaimer'/><span style="width:350px;">Text of the Disclaimer Here </span></span>');
</script>

Just want to double check.  Had to reinstall XP on my mac and will need to also install other software to be able to test this.
0
 
atljarmanConnect With a Mentor Author Commented:
What if I wanted to exclude specific domains as well as class="internal".  For example, what if I want to not have the disclaimer on any site that includes google.com or yahoo.com or includes the class internal?  I've increased the value to 350.  Thanks for your help.
0
 
atljarmanAuthor Commented:
Thanks for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.