jQuery target blank link


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

Add class external to all target=_blank links


Copy this code and paste it in your HTML
  1. /**
  2.  * From jQuery 1.3+ release, avoid (at) char
  3.  */
  4. jQuery('a[target=_blank]').addClass('external');
  5.  
  6. /**
  7.  * Before jQuery 1.3 release
  8.  */
  9. jQuery('a[@target=_blank]').addClass('external');
  10. //
  11. /**
  12.  * css
  13.  
  14. .external{background:url(images/external.png) no-repeat right 3px;padding-right:14px}
  15.  
  16. */

URL: http://www.undolog.com/2008/12/15/very-short-snippet-jquery-auto-target-blank-link/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.