title: Simulating Button click in javascript
body: <p>So what i want to do is when i click on a button, it will pass this click event to another element in webpage, or you can say it will create a new click event in another element. Below is my code, it does not work, please let me know what is wrong with it, it looks make sense...</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8" /&gt;
  &lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" /&gt;
  &lt;script src="http://code.jquery.com/jquery-1.8.3.js"&gt;&lt;/script&gt;
  &lt;script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"&gt;&lt;/script&gt;
  &lt;link rel="stylesheet" href="/resources/demos/style.css" /&gt;
  &lt;script&gt;
  $(function() {
  $( "#datepicker" ).datepicker();
  });
  
  
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;p&gt;Date: &lt;input type="text" id="datepicker" onClick=alert("error") /&gt;&lt;/p&gt;
  &lt;button type="button" value="submit" onClick="document.getElementById("datepicker").click()"&gt;submit &lt;/button&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>