Saturday, 28 September 2013

Add Javascript Variable To End Of Link

Add Javascript Variable To End Of Link

I am trying to create a hyperlink based on the location that is sent to me.
for example:
var location = 12345 stackoverflow drive
html code:
<div id="add"></div>
js:
$('#add').append('<a href="http://maps.google.com/?q= **location**
>Click</a>');
However, this link does not take me to the variable location, it actually
searches the word "location" How would I fix this?
jsFiddle:
http://jsfiddle.net/LPZsA/

No comments:

Post a Comment