A jQuery Plugin that enables downloading a file directly from a link instead of opening it
![License: MIT](https://camo.githubusercontent.com/6552afb9038154d801c50b6e55a76db78a6787a8d6e2b5252a44864503c52887/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)
- Import the jQuery library
- Load the download-r script in your HTML after the body
<script type="text/javascript" src="jquery.download-r.min.js"></script>
- Use the following call to activate the plugin
$(document).ready(function(){
$(document).downloadr();
});
- Add an
<a>
tag to your HTML
<a class="download-r" href="foo/bar.pdf">
Attribute |
Description |
class |
Used to identify the links that are downloadable |
href |
Link to file that is to be downloaded |
- Use JSON to change the options
- Example of changing the link selector class:
$(document).downloadr({
elements: {
selectors: {
link: '.download-link',
}
}
});
Option |
Description |
Default value |
elements.selectors.link |
The selector used to identify the download links |
.download-r |
![forthebadge](https://camo.githubusercontent.com/06d6241db408022e6abd3551485ec628a3d8cb2c7688d8acb51fc3d64a6d7746/68747470733a2f2f666f7274686562616467652e636f6d2f696d616765732f6261646765732f6d6164652d776974682d6a6176617363726970742e737667)