Posted By

Alwaison on 02/25/11


Tagged

link jquery rel blanl extern


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

espig


Blank target links with jQuery


 / Published in: jQuery
 

  1. /**
  2.  * Convert the links with rel="external"
  3.  *
  4.  * v. 0.1 Updated (07/02/11)
  5.  * - Changed de CSS selector adding the posibility to external wasn't the only string in rel
  6.  * attribute.
  7.  * - Changed de string from "extern" to "external", that's looks more adequate.
  8.  *
  9.  */
  10. function initRelLinks(){
  11. jQuery('a[rel*="external"]').click(function(){
  12. jQuery(this).attr('target', '_blank');
  13. });
  14. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: AllKnightAccess on February 25, 2011

Or you can use this:

jQuery('a[rel="extern"]').each(function() { jQuery(this).attr('target', '_blank'); });

Posted By: Alwaison on March 2, 2011

Of course AllKnightAccess, thats another solution ;)

You need to login to post a comment.