title: trigger tab press key event on page load
body: <p>I have a request where on page load I should trigger the tab press keyboard event. I tried below example but it does not work.</p>
  
  <p>My requirement is to set focus on a element in parent html page on page load, but I do not have access to the source code of this parent page. My html page is part of the parent as a frame. So on load of my page (parent is already loaded) I want to trigger the tab press key event to set the focus on the element from parent. </p>
  
  <p>Note : This element is the first element in the parent page and hence on first tab the focus shifts to this. I cannot edit the parent page</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
     &lt;head&gt;
        &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"&gt;&lt;/script&gt;
        &lt;script&gt;
           $(document).ready(function(){
            $("#input1").focus();
               var press = jQuery.Event("keypress");
               press.which = 9;
               $("#input1").trigger(press);
           });
           
           
        &lt;/script&gt;
     &lt;/head&gt;
     &lt;body&gt;
        &lt;input type="text" name="myInput1" id="input1" /&gt;
        &lt;input type="text" name="myInput2" id="input2" /&gt;
        &lt;input type="text" name="myInput3" id="input3" /&gt;
     &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>