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