JSFiddle - React, Tailwind, and code Playground

by Mirawen

HTML

<div>
  <input type="text" id="txtSearch" onkeypress="keyPress(event);" />
  <button type="button" title="Search" onclick="MainFunction();">Search
  </button>
</div>

JavaScript

function keyPress(keyEvent)
{  
  if (keyEvent.which == 13)
    MainFunction();
}

function MainFunction()
{
	alert("Hello World");
}

var arrSource = ["foo", "foooo", "foooooo", "bar", "barr", "barr"];

$(document).ready(function() {
  $("#txtSearch").autocomplete(
    {
        source: arrSource,
        minLength: 1,
        select: function (event, ui)
        {
          MainFunction(); 
        }
    });
});