1

I a trying to download file when user click on "download like".I found this link .it open file.Not start download file automatically. Download File Using jQuery.\

http://jsfiddle.net/fXwqA/

$('a').click(function(e) {
    e.preventDefault();  //stop the browser from following
    window.location.href = 'http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css';
});

It should start download automatically .

Community
  • 1
  • 1

1 Answers1

0

There's no need in jQuery, just add "download" attribute to your anchor:

<a download href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">
   Download now!
</a>

Demo: http://jsfiddle.net/ygalanter/fXwqA/1/

Yuriy Galanter
  • 38,833
  • 15
  • 69
  • 136