Blank target links with jQuery


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  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

You need to login to post a comment.