Reputation:
If I have an array how can I create a link of on of the values...www.vermont.gov
This is a part of a switch:
case "b1": // Vermont
kf= new Array("Governor : Peter Shumlin","Size in Square Miles: 9,623","Population: 626,562","Founded: March 4th 1791","www.vermont.gov")
mb = 'images/vermontst.jpeg';
mt = 'images/vermontbird.jpg';
ml = 'images/vermontflower.jpeg';
tt = "Vermont";
break;
document.getElementById("title").innerHTML=tt;
document.getElementById("left").style.color=fg;
document.getElementById("left").style.fontSize="30px";
document.getElementById("fac").style.marginLeft="120px";
document.getElementById("fac").style.lineHeight="70px";
document.getElementById("pic").src=mb;
document.getElementById("pict").src=mt;
document.getElementById("picl").src=ml;
document.getElementById("fac").innerHTML = kf.join(" <br/> ");
Upvotes: 0
Views: 46
Reputation: 2623
In this case, the last element of your array could just be something like this:
"<a href='http://www.vermont.gov'>www.vermont.gov</a>"
Upvotes: 0
Reputation: 6896
You can create a <a>
tag and then append to it the value of the link from the array using an index
.
var a = document.createElement('a');
var linkText = document.createTextNode("my title text");
a.appendChild(linkText);
a.title = "my title text";
a.href = kf[4];
document.body.appendChild(a);
Upvotes: 1