Change Attribute Values for Links

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

If you wish to change attributes in a link you can make use of this snippet.
For example, you can add "name", "id", "class", "target", etc.

Copy this code and paste it in your HTML
  1. $(document).ready(function(){
  2. $(function(){
  3. $("a[href^='http']").attr('target','_blank');
  4. $("a[href^='.pdf']").attr('target','_blank');
  5. $("a[href^='']").attr('target','_blank');
  6. });
  7. });

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.