How to Download File using jQuery?

AuthorSumit Dey Sarkar

Pubish Date27 Nov 2022

categoryJQuery

In this tutorial we will learn how to download file using jQuery?

Here we will use window.location to download any file or image using jQuery.

 

Let's see an example -

 

How to download file using jQuery?

<!DOCTYPE html>
<html>
<head>
    <title>How to Download File using jQuery?</title>
</head>
<body>
  
    <h1>How to Download File using JQuery?</h1>
  
    <a class="downloadUsingJquery" href="#">Download Now</a>
  
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $(".downloadUsingJquery").click(function (e) {
            e.preventDefault();
            window.location.href = "https://teknowize.com/attachments/file_1669493714.png";
        });
    });
</script>
  
</html>
Comments 0

Leave a comment