-4

How can I add a Url to the href tag with javascript? Can you help, please?

<a id="url-link" href="" onclick="" title="" class="btn">CLICK</a>

https://jsfiddle.net

2
  • 2
    What did you try so far? if you searched for set attribute value javascript, you will get what you need exactly. Commented Mar 25, 2016 at 21:17
  • 5
    I am guessing you didn't search for an answer before asking. many examples available: stackoverflow.com/questions/4365246/… Commented Mar 25, 2016 at 21:17

1 Answer 1

2

Try this

var a = document.getElementById('url-link');
a.href="your link here";
Sign up to request clarification or add additional context in comments.

2 Comments

Its good to answer questions. But when questions are trivial, it is good to "ask" or "guide" OP to discovering the answer themselves.
Thank you, Veniamin. Works great!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.