how to add a href in javascript code example
Example 1: javascript set attribute href
var a = document.getElementById('myElementID');
a.href = "http://www.mywebsite.com";
Example 2: create a link javascript
<html>
<head></head>
<body>
<script>
var a = document.createElement('a');
var linkText = document.createTextNode("my title text");
a.appendChild(linkText);
a.title = "my title text";
a.href = "http://example.com";
document.body.appendChild(a);
</script>
</body>
</html>