Thursday, May 16, 2013

Add class to link which contains ".pdf" file

Add pdf icon to whole site pdf URLwhich are in the content_area.

In jQuery a[href*=".pdf"]' syntax contains all the elements which link ref contain .pdf
Add specific class to PDF links.

$('.content_area a[href*=".pdf"]').addClass('pdf_doc');

Apply below css to given class to add PDF icon to link to highlight.

.pdf_doc {
background: url("pdf.png") no-repeat scroll left 0;
padding-left: 20px;
background-size: 18px;