Automatically Discover Document Links And Apply Class


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



Copy this code and paste it in your HTML
  1. $('a[href]').each(function() {
  2.    if((C = $(this).attr('href').match(/[.](doc|xls|pdf)$/))) {
  3.        $(this).addClass(C[1]);
  4.    }
  5. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.