Reputation: 173
I've made this little script which takes my embedded video and converts it to a download link, hence the var src = str.replace("/e/", "/d/");
however, how can I now send this download link into a href ?
<body onload="myFunction123()">
<a href="#" type="button" class="btn btn-theme-lt mr-2 px-md-5 mb-2" id="demo">Download</a>
<script>
function myFunction123() {
var str = document.getElementById("download_link").src;
var src = str.replace("/e/", "/d/");
document.getElementById("demo").href = src;
}
</script>
</body>
Upvotes: 0
Views: 52
Reputation: 12035
You should use setAttribute
:
function myFunction123() {
var str = document.getElementById("download_link").src;
var src = str.replace("/e/", "/d/");
document.getElementById("demo").setAttribute("href", src);
}
Upvotes: 2