Posted By

beso on 11/05/10


Tagged

css class link pdf


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

maltem
chendrix


Auto add a class to link files (pdf,doc,external)


 / Published in: jQuery
 

  1. $(document).ready(function(){
  2. $("a[href$='.pdf']").addClass("pdf");
  3. $("a[href$='.doc']").addClass("doc");
  4. //Add external link icon to external links -
  5. $('a').filter(function() {
  6. //Compare the anchor tag's host name with location's host name
  7. return this.hostname && this.hostname !== location.hostname;
  8. }).addClass("external").attr("target","_blank");
  9. });

Report this snippet  

You need to login to post a comment.