jeremyll
asked on
JQuery:Automatic Insertion of Icons for PDF Links
Aim: to place a pdf icon at the end of a hyperlink.
HTML code:
<a href="#">This is a blue document (PDF, 2.3MB)</a>
Front end output:
This is a blue document (PDF, 2.3MB) [imageIcon]
If the value inside the anchor tag contains '(PDF,' and ends with 'b)' ('b' can be either lower or uppercase) then append the image icon at the end.
This is the code I've been trying to fiddle with to get the above criteria:
<script type="text/javascript" src="../jquery-1.3.2.js">< /script>
<script type="text/javascript">
$("document").ready(functi on() {
// $("li a[href$=.pdf]").after("<im g src='images/small_pdf_icon .gif' align='absbottom' />");
$("p=.pdf]").after("<img src='images/small_pdf_icon .gif' align='absbottom' />");
//$("a[pdf][href$=.pdf]"). after("<im g src='images/small_pdf_icon .gif' align='absbottom' />");
$("p*=PDF").after("<img src='images/small_pdf_icon .gif' align='absbottom' />");
});
</script>
HTML code:
<a href="#">This is a blue document (PDF, 2.3MB)</a>
Front end output:
This is a blue document (PDF, 2.3MB) [imageIcon]
If the value inside the anchor tag contains '(PDF,' and ends with 'b)' ('b' can be either lower or uppercase) then append the image icon at the end.
This is the code I've been trying to fiddle with to get the above criteria:
<script type="text/javascript" src="../jquery-1.3.2.js"><
<script type="text/javascript">
$("document").ready(functi
// $("li a[href$=.pdf]").after("<im
$("p=.pdf]").after("<img src='images/small_pdf_icon
//$("a[pdf][href$=.pdf]").
$("p*=PDF").after("<img src='images/small_pdf_icon
});
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Proculopsis, That's great. How can I put just one space between the imageicon and the anchor tag?
ASKER
I'm actually using another image, which doesn't have sufficient white space to provide a gap.
ASKER
Proculopsis - LEGEND
ASKER
Also, can this work without google's api?
Thanks!