I can't figure this one out...
Could someone please help me en explain how it works to?
Goal: Adding a variable to a hard-coded URL, and put the new string into a href
Example:
var x = "1000";
var y = "http://www.google.com"
var result = y + x;
<a href="! the value of result !">click here...</a>
Edit i'm sorry i meant y + x ofcourse...
JavaScript:
jQuery:
Give your Link an ID.
<a id="lnkTarget" href="#">click here...</a>
Add a reference to JQuery JavaScript Library.
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
Get a handle on the link with a JQuery Selector and use the attr function.
$('#lnkTarget').attr('href', result);
Given this HTML code:
<a href="" target="_blank">click here...</a>
You would need this bit of js code: (working example http://jsfiddle.net/QUEZL)
Try
HREF is an attribute so you can access it via
.attr()
For me, all the above approaches were replacing the variable with the latest value of the variable as it was referred in a loop.
Solution: