href setattribute javascript code example
Example 1: javascript set attribute href
var a = document.getElementById('myElementID');
a.href = "http://www.mywebsite.com";
Example 2: javascript change attribute
var element = document.getElementById("elemId");
element.setAttribute("attributeName", "value");
Example 3: set attribute javascript
Element.setAttribute(name, value);