Reputation: 173
I been stuck with this problem for a while.
All I need is to put a link inside an array that will call a function to change some text.
<!DOCTYPE html>
<html>
<body>
<p id="demo">The link</p>
<p id="demo1">This content should be be changed when I click the text above</p>
<script>
var text = ["<a href=javascript:Test(demo1, milk)>Click me to change text below to milk</a>"];
document.getElementById("demo").innerHTML = text[0];
function Test(id, content){
var container = document.getElementById(id);
container.innerHTML = content;
}
</script>
</body>
</html>
This works if the link is placed outside an array, but inside an array it doesn't.
Any pointers on how I can get this to work? Been trying for 8 hours now. Thanks guys I would really appreciate your assistance.
Upvotes: 2
Views: 218