Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jqueryonclick,选择输入框并按enter键(呈现html)_Javascript_Jquery_Html - Fatal编程技术网

Javascript jqueryonclick,选择输入框并按enter键(呈现html)

Javascript jqueryonclick,选择输入框并按enter键(呈现html),javascript,jquery,html,Javascript,Jquery,Html,当用户单击html div searchboxquicktab时,我希望光标移动到一个输入框,它应该模拟按下enter键,这样就可以显示单击的结果 以下是html: <div class="form-type-textfield form-item-title form-item form-group"> <input placeholder="Start typing a name here to filter listing..." class="form-control

当用户单击html div searchboxquicktab时,我希望光标移动到一个输入框,它应该模拟按下enter键,这样就可以显示单击的结果

以下是html:

<div class="form-type-textfield form-item-title form-item form-group">
 <input placeholder="Start typing a name here to filter listing..." class="form-control form-text ctools-auto-submit-processed" id="edit-title" name="title" value="" size="30" maxlength="128" type="text">
 <div id="searchboxquicktab">
  <span class="glyphicon glyphicon-search"></span>Search
 </div>
</div>

但这不起作用。

任何监听按键事件的人都会收到触发按键事件的消息,但它们不会影响输入。我已经测试了你的代码,事件实际上正在被触发

也就是说,我在过去使用了一个名为jQuery.sendkeys.js的jQuery插件来模拟击键

注意:jquery.sendkeys.js需要biliterange.js。
.

是否已经有一个处理程序,用于处理用户实际按enter键的时间?如果是这样,只需调用该处理程序,而不是触发按键
// Select textbox and press enter key to show results.
$('.form-item-title').on("click", "#searchboxquicktab", function() {
  console.log('search box quicktab button pressed.');
  var e = jQuery.Event("keydown");
  e.which = 13; // Enter
  $('input.ctools-auto-submit-processed').focus().trigger(e);
});