当用户在文本框中键入内容时,我正在使用带有select to autocomplete的自动完成功能来显示自动完成的国家/地区名称,并且在提交时,用户会转到指定的URL .

问题是,当用户按下提交按钮时它会起作用,但是当他们按下回车键时,或者使用iOS键盘上的“开始”按钮时,它就会起作用 .

<head>  
(function($){
  $(function(){
    $('select').selectToAutocomplete();

  });
})(jQuery)
</head>

<body>
<form class="countryform" name="countryform">
<select name="Country" id="country-selector" autofocus="autofocus" autocorrect="off" autocomplete="off" placeholder="Type your country" style="width:50%;" >
  <option value="" selected="selected"></option>

  <option value="http://www.qmul.ac.uk/international/international-students/countries/other/index.html" data-alternative-spellings="ZM">Zambia</option>
  <option value="http://www.qmul.ac.uk/international/international-students/countries/Zimbabwe/index.html" data-alternative-spellings="ZW">Zimbabwe</option>
</select>

<input type="button" onclick="window.open(this.form.Country.options[this.form.Country.selectedIndex].value,'_top')" value="Submit">
</body>

我怀疑标签中的onclick需要有点聪明 . 我尝试通过jQuery进行表单提交,但它不起作用 . 谁来帮帮我?

谢谢