How to insert value in html attribute with javascript [duplicate]

2

A doubt

How to insert a value inside an href="" attribute with javascript

    
asked by anonymous 02.07.2016 / 07:30

1 answer

1

just get the link and then set the value in the href attribute, follow an example code:

<a href="#" id="link">Teste</a>

var link = document.getElementById('link');
link.href = 'http://google.com'
    
02.07.2016 / 08:07