tags:

views:

23

answers:

1

Let's say I have:

var url="http://www.google.html";

how do I put the url variable value as the href value of an specific anchor tag in the page? I know about str.link() but how I can use that with an specific element? and can I use link*( to build anchors of images? That didn't seem to work for me. Thanks for the help

+4  A: 

For anchor elements:

<a id="myAnchor">link me!</a>

...

<script type="text/javascript">
var url = "http://www.google.html";  // .html is the new .com
var myAnchor = document.getElementById('myAnchor');
myAnchor.href = url;
</script>
strager
haha lol thanks for your clear reply!
elramirez