How to insert value into html attribute with javascript

Asked

Viewed 396 times

2

A doubt

How to insert a value into a href="" attribute with javascript

1 answer

1

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

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.