Automatically Discover Document Links And Apply Class

0
0
$('a[href]').each(function() {
   if((C = $(this).attr('href').match(https://cdn.pak26.com/[.](doc|xls|pdf)$/))) {
       $(this).addClass(C[1]);
   }
});

This will look through every a element on the page. If the href attribute of it has a .doc, .xls, or .pdf in it, it will apply the appropriate class name to it (e.g. class="doc")

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.