I am targeting links containing various types of files in jQuery using:
jQuery('a[href$=".pdf"], a[href$=".doc"], a[href$=".docx"], a[href$=".ppt"], a[href$=".pptx"], a[href$=".xls"], a[href$=".slxs"], a[href$=".epub"], a[href$=".odp"], a[href$=".ods"], a[href$=".txt"], a[href$=".rtf"]').before('<span class="glyphicon glyphicon-file"></span> ');
Firstly, is there a way to reduce recurrence? eg.
jQuery('a[href$=".pdf|.doc|.docx"])
And secondly, is there a way to configure various cases for file extensions, for example. Pdf, Pdfand Pdf?
source
share