set a tag href javascript code example
Example 1: change href for a tag using JS
document.getElementById("myAnchor").href = "http://www.cnn.com/";
Example 2: javascript set attribute href
var a = document.getElementById('myElementID');
a.href = "http://www.mywebsite.com";