jQuery: Finding file size and adding it to the link
Posted
by
Ricardo
on Stack Overflow
See other posts from Stack Overflow
or by Ricardo
Published on 2013-06-24T16:08:20Z
Indexed on
2013/06/24
16:21 UTC
Read the original article
Hit count: 162
jQuery
Let me start by saying that I'm not a jQuery guru by any means and I genuinely know this is over my head, that's why I've come to SO.
Is there a way with jQuery to find the file size of a link on a page and then inject/add the text of the file size next to the link?
Here's my problem
On one of my pages, I have a link to my resume which is a PDF file and to improve usability it's proper to have the file type and file size next to the link so the users have the option to decide if they want to click on that link or not. So the link would read something like "Download my resume (PDF / 80KB)"
The problem is that I'm constantly updating my resume and uploading a new PDF file which, of course, has a different file size so I'm always going back to the HTML and changing the text to reflect the new file size.
Is there a way to automate this with jQuery... or plain JavaScript for that matter?
I found this script and made a demo here in Codepen but it doesn't seem to work.
Any help with this would be greatly appreciated.
© Stack Overflow or respective owner