0

I want to change belo url using javascript

From:

<a class='button' href="#" target="_blank" id="download_link" style="display: none;"><i class='icon download'></i>Download Now</a>

To

<a class='button' href="https://google.com" target="_blank" id="download_link" style="display: none;"><i class='icon download'></i>Download Now</a>

My code is

<a class='button' href="#" target="_blank" id="download_link" style="display: none;"><i class='icon download'></i>Download Now</a>
<script type="application/javascript">
 var tURL = "https://google.com"
 var download_link = document.getElementById("download_link");
 download_link.innerHTML.replace("#", tURL);

where I do mistake please correct this. I know it is easy to use hyper link in html. but I want to replace urls using javascript

1

1 Answer 1

2
var download_link = document.getElementById("download_link");
download_link.href = tURL;

or

var download_link = document.getElementById("download_link");
download_link.setAttribute('href', tURL);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.