I need something like this:
var link = " http://www.google.com";
<a href='link' />
"<a href= '" + link + "' />"
You should set the href value on the server, it is bad design to use scripting for this.
However, to answer the question, it can be done by using script to set the href property of the A element once it is in the DOM, e.g.:
Of course there are a thousand other ways, all with their pitfalls. So set the value on the server and avoid them all.