title: Automatically trigger an Enter key press after write text into a search box?
body: <p>I'm writing some code to trigger <kbd>Enter</kbd> right after I put the text I got from an img alt into a search box.</p>
  
  <p>I'm working with jQuery DataTables. But I want to create my own filter outside the table. I want to have icons to click to filter the table.</p>
  
  <p>Because jQuery DataTables can pull out result if you put text in the search box, I figured that if I can get the text from the img alt and write the text into the search box, it will do the filtering.</p>
  
  <p>But it didn't work, it needs to be entered.</p>
  
  <p>So how can I trigger the <kbd>Enter</kbd>? Or it's just a completely wrong idea to do this way?</p>
  
  <pre><code> &lt;img alt="High School" src="../../slack.png" class="icon"&gt;&lt;/img&gt;
      &lt;script&gt;
      $(function(){
        $('.icon').on('click', function(){
         var text = $('.icon').first().attr("alt");
        $('.dataTables_wrapper .dataTables_filter input').val(text);
        $('input').submit();
        })
      })
     &lt;/script&gt;
  </code></pre>
  
  <p>Update on the post. It's solved and it can work with dataTable.
  Here's the code:</p>
  
  <pre><code>&lt;img alt="High School" src="../../slack.png" class="icon" id="High School"&gt;&lt;/img&gt;
      &lt;img alt="Elementary School" src="../../ai.png" class="icon" id="Elementary School"&gt;&lt;/img&gt;
  &lt;script&gt;
  var e = jQuery.Event("keyup");
  e.which = 13;
  $(function(){
    $('.icon').on('click', function(){
     var text = $(this).attr("id");
    $('.dataTables_wrapper .dataTables_filter input').val(text);
    $('input').trigger('keyup',e);
  
    })
  })
  </code></pre>