title: Simulating click event inside JavaScript OnClick results in error
body: <p>I am building a context menu with some options using <code>&lt;li&gt;</code> tags as shown below. I need to simulate click event on another ID (image), When i choose and click on this option from context menu.. I can only have the function instantaneous execution inside onclick as shown in below code- </p>
  
  <p><strong>Edited the code to give more clarity</strong></p>
  
  <pre><code>var functionMain = function ContextMenu$functionMain(items, targetId) {
      $(menu).html(buildItems(items, targetId));
  };
  
  var buildItems = function ContextMenu$buildItems(items, targetId) {
      var i, result;
      result = '';
      for (i = 0; i &lt; items.length; ++i) {
          var reportId = targetId.substring(targetId.indexOf(':') + 1);
          var reportIdFormed = $('#' + reportId + 'run' + runReportLinkName);
          result += '&lt;li&gt;&lt;a href="javascript:void(0);" style="text-decoration:none" onclick="(function(){'+ reportIdFormed+'.trigger(\'click\'); })();"&gt; Run HTML &lt;/a&gt;&lt;/li&gt;';
      }
      return result;
  };
  </code></pre>
  
  <p>Above code is resulting in <strong>Uncaught SyntaxError: Unexpected identifier</strong></p>
  
  <p>Resultant HTML --> <code>&lt;a href="javascript:void(0);" style="text-decoration:none" onclick="(function(){[object Object].trigger('click'); })();"&gt;Run HTML&lt;/a&gt;</code></p>
  
  <p>How to get rid of this issue?</p>