title: javascript pass function to onclick event
body: <p>I have to write a function which will create a HTML code of <code>a</code> tag and this function will also pass a function handler to <code>onclick</code> event of created <code>a</code> tag.
  Code:  </p>
  
  <pre><code>function a(text,functionHandler){
      return '&lt;a href="#" onclick="'+functionHandler+'"&gt;'+text+'&lt;/a&gt;';
  }
  
  //usage
  var a1 = a('link',function(){
     alert('test');
  });
  </code></pre>
  
  <p>Passing the function to string doesn't work.
  So my question is: <code>how to pass a function handle to onclick event and get a HTML code of created a tag?</code></p>