Link to home
Start Free TrialLog in
Avatar of atljarman
atljarman

asked on

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 (https://www.experts-exchange.com/questions/27974488/JQuery-replacement-of-closing-hyperlink-tag-if-http-is-in-the-href-tag.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.
Avatar of soupBoy
soupBoy
Flag of United States of America image

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()
Avatar of atljarman
atljarman

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of soupBoy
soupBoy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help.